diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs index 432d0695b..d062abd45 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs @@ -40,4 +40,5 @@ [assembly: AssemblyInformationalVersion("1.1.0-dev")] [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCopTester, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..8c1f7537c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,31 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class AccessorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestExpressionBody() + { + var accessorDeclarationSyntax = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration) + .WithExpressionBody(SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Same(accessorDeclarationSyntax.ExpressionBody, AccessorDeclarationSyntaxExtensions.ExpressionBody(accessorDeclarationSyntax)); + } + + [Fact] + public void TestWithExpressionBody() + { + var accessorDeclarationSyntax = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var accessorWithBody = AccessorDeclarationSyntaxExtensions.WithExpressionBody(accessorDeclarationSyntax, expressionBody); + Assert.Null(accessorDeclarationSyntax.ExpressionBody); + Assert.NotNull(accessorWithBody.ExpressionBody); + Assert.Equal(SyntaxKind.NullLiteralExpression, accessorWithBody.ExpressionBody.Expression.Kind()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..8d3399299 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,20 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class BaseMethodDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestExpressionBody() + { + var syntax = SyntaxFactory.ConstructorDeclaration(SyntaxFactory.Identifier("Anything")) + .WithExpressionBody(SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Same(syntax.ExpressionBody, BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..bd73f5aec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ConstantPatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + Assert.Null(constantPatternSyntax.SyntaxNode); + Assert.Throws(() => constantPatternSyntax.Expression); + Assert.Throws(() => constantPatternSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestExpression() + { + var syntaxNode = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.True(syntaxNode.IsKind(SyntaxKind.ConstantPattern)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.ConstantPattern)); + + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, constantPatternSyntax.SyntaxNode); + Assert.Same(syntaxNode.Expression, constantPatternSyntax.Expression); + + constantPatternSyntax = constantPatternSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(1))); + Assert.NotNull(constantPatternSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, constantPatternSyntax.SyntaxNode); + Assert.Equal(SyntaxKind.NumericLiteralExpression, constantPatternSyntax.Expression.Kind()); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ConstantPatternSyntaxWrapper.IsInstance(null)); + Assert.False(ConstantPatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.True(ConstantPatternSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = constantPatternSyntax; + Assert.Null(patternSyntax.SyntaxNode); + + constantPatternSyntax = (ConstantPatternSyntaxWrapper)patternSyntax; + Assert.Null(constantPatternSyntax.SyntaxNode); + + SyntaxNode syntax = constantPatternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = constantPatternSyntax; + Assert.Same(syntaxNode, patternSyntax.SyntaxNode); + + constantPatternSyntax = (ConstantPatternSyntaxWrapper)patternSyntax; + Assert.Same(syntaxNode, constantPatternSyntax.SyntaxNode); + + SyntaxNode syntax = constantPatternSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ConstantPatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..0c4ed397c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ConstructorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestWithExpressionBody() + { + var syntax = SyntaxFactory.ConstructorDeclaration(SyntaxFactory.Identifier("Anything")); + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var syntaxWithBody = ConstructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, expressionBody); + Assert.Null(syntax.ExpressionBody); + Assert.NotNull(syntaxWithBody.ExpressionBody); + Assert.Equal(SyntaxKind.NullLiteralExpression, syntaxWithBody.ExpressionBody.Expression.Kind()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..ffb474e89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs @@ -0,0 +1,106 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DeclarationPatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + Assert.Null(declarationPatternSyntax.SyntaxNode); + Assert.Throws(() => declarationPatternSyntax.Type); + Assert.Throws(() => declarationPatternSyntax.Designation); + Assert.Throws(() => declarationPatternSyntax.WithType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)))); + Assert.Throws(() => declarationPatternSyntax.WithDesignation((VariableDesignationSyntaxWrapper)SyntaxFactory.DiscardDesignation())); + } + + [Fact] + public void TestProperties() + { + var syntaxNode = SyntaxFactory.DeclarationPattern( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.DiscardDesignation()); + Assert.True(syntaxNode.IsKind(SyntaxKind.DeclarationPattern)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.DeclarationPattern)); + + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, declarationPatternSyntax.SyntaxNode); + Assert.Same(syntaxNode.Type, declarationPatternSyntax.Type); + Assert.Same(syntaxNode.Designation, declarationPatternSyntax.Designation.SyntaxNode); + + declarationPatternSyntax = declarationPatternSyntax.WithType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + Assert.NotNull(declarationPatternSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, declarationPatternSyntax.SyntaxNode); + Assert.Same(((DeclarationPatternSyntax)declarationPatternSyntax.SyntaxNode).Type, declarationPatternSyntax.Type); + + declarationPatternSyntax = declarationPatternSyntax.WithDesignation((VariableDesignationSyntaxWrapper)SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("Anything"))); + Assert.NotNull(declarationPatternSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, declarationPatternSyntax.SyntaxNode); + Assert.Same(((DeclarationPatternSyntax)declarationPatternSyntax.SyntaxNode).Designation, declarationPatternSyntax.Designation.SyntaxNode); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(DeclarationPatternSyntaxWrapper.IsInstance(null)); + Assert.False(DeclarationPatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.DeclarationPattern( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.DiscardDesignation()); + Assert.True(DeclarationPatternSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = declarationPatternSyntax; + Assert.Null(patternSyntax.SyntaxNode); + + declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)patternSyntax; + Assert.Null(declarationPatternSyntax.SyntaxNode); + + SyntaxNode syntax = declarationPatternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.DeclarationPattern( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.DiscardDesignation()); + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = declarationPatternSyntax; + Assert.Same(syntaxNode, patternSyntax.SyntaxNode); + + declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)patternSyntax; + Assert.Same(syntaxNode, declarationPatternSyntax.SyntaxNode); + + SyntaxNode syntax = declarationPatternSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (DeclarationPatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..744d295a6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DestructorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestWithExpressionBody() + { + var syntax = SyntaxFactory.DestructorDeclaration(SyntaxFactory.Identifier("Anything")); + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var syntaxWithBody = DestructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, expressionBody); + Assert.Null(syntax.ExpressionBody); + Assert.NotNull(syntaxWithBody.ExpressionBody); + Assert.Equal(SyntaxKind.NullLiteralExpression, syntaxWithBody.ExpressionBody.Expression.Kind()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..a979b294a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DiscardDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + Assert.Null(discardDesignationSyntax.SyntaxNode); + Assert.Throws(() => discardDesignationSyntax.UnderscoreToken); + Assert.Throws(() => discardDesignationSyntax.WithUnderscoreToken(SyntaxFactory.Token(SyntaxKind.UnderscoreToken))); + } + + [Fact] + public void TestUnderscoreToken() + { + var syntaxNode = SyntaxFactory.DiscardDesignation(); + Assert.True(syntaxNode.IsKind(SyntaxKind.DiscardDesignation)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.DiscardDesignation)); + + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, discardDesignationSyntax.SyntaxNode); + Assert.Equal(syntaxNode.UnderscoreToken, discardDesignationSyntax.UnderscoreToken); + + discardDesignationSyntax = discardDesignationSyntax.WithUnderscoreToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.UnderscoreToken))); + Assert.NotNull(discardDesignationSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, discardDesignationSyntax.SyntaxNode); + Assert.False(syntaxNode.UnderscoreToken.IsEquivalentTo(discardDesignationSyntax.UnderscoreToken)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(DiscardDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(DiscardDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.DiscardDesignation(); + Assert.True(DiscardDesignationSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = discardDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(discardDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = discardDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.DiscardDesignation(); + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = discardDesignationSyntax; + Assert.Same(syntaxNode, variableDesignationSyntax.SyntaxNode); + + discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Same(syntaxNode, discardDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = discardDesignationSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (DiscardDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs new file mode 100644 index 000000000..18e08b30d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs @@ -0,0 +1,99 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class IsPatternExpressionSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + Assert.Null(isPatternExpressionSyntax.SyntaxNode); + Assert.Throws(() => isPatternExpressionSyntax.Expression); + Assert.Throws(() => isPatternExpressionSyntax.IsKeyword); + Assert.Throws(() => isPatternExpressionSyntax.Pattern); + Assert.Throws(() => isPatternExpressionSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => isPatternExpressionSyntax.WithIsKeyword(SyntaxFactory.Token(SyntaxKind.IsKeyword))); + Assert.Throws(() => isPatternExpressionSyntax.WithPattern((PatternSyntaxWrapper)SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)))); + } + + [Fact] + public void TestProperties() + { + var syntaxNode = SyntaxFactory.IsPatternExpression(SyntaxFactory.DefaultExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))), SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.True(syntaxNode.IsKind(SyntaxKind.IsPatternExpression)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.IsPatternExpression)); + + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, isPatternExpressionSyntax.SyntaxNode); + Assert.Same(syntaxNode.Expression, isPatternExpressionSyntax.Expression); + Assert.True(syntaxNode.IsKeyword.IsEquivalentTo(isPatternExpressionSyntax.IsKeyword)); + Assert.Same(syntaxNode.Pattern, isPatternExpressionSyntax.Pattern.SyntaxNode); + Assert.Equal(SyntaxKind.NullLiteralExpression, ((ConstantPatternSyntax)isPatternExpressionSyntax.Pattern).Expression.Kind()); + + var newExpression = SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(0)); + var modifiedExpression = isPatternExpressionSyntax.WithExpression(newExpression); + Assert.NotNull(modifiedExpression.SyntaxNode); + Assert.NotSame(syntaxNode.Expression, modifiedExpression.Expression); + Assert.Equal(SyntaxKind.NumericLiteralExpression, modifiedExpression.Expression.Kind()); + + var newIsKeyword = SyntaxFactory.Token(SyntaxKind.IsKeyword).WithLeadingTrivia(SyntaxFactory.Space); + var modifiedIsKeyword = isPatternExpressionSyntax.WithIsKeyword(newIsKeyword); + Assert.NotNull(modifiedIsKeyword.SyntaxNode); + Assert.Equal(1, modifiedIsKeyword.IsKeyword.LeadingTrivia.Count); + Assert.Equal(" ", modifiedIsKeyword.IsKeyword.LeadingTrivia.ToString()); + + var newPattern = SyntaxFactory.ConstantPattern(newExpression); + var modifiedPattern = isPatternExpressionSyntax.WithPattern((PatternSyntaxWrapper)newPattern); + Assert.NotNull(modifiedPattern.SyntaxNode); + Assert.Equal(SyntaxKind.DefaultExpression, modifiedPattern.Expression.Kind()); + Assert.Equal(SyntaxKind.NumericLiteralExpression, ((ConstantPatternSyntax)modifiedPattern.Pattern).Expression.Kind()); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(IsPatternExpressionSyntaxWrapper.IsInstance(null)); + Assert.False(IsPatternExpressionSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.IsPatternExpression(SyntaxFactory.DefaultExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))), SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.True(IsPatternExpressionSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = isPatternExpressionSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.IsPatternExpression(SyntaxFactory.DefaultExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))), SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = isPatternExpressionSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (IsPatternExpressionSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs new file mode 100644 index 000000000..235678f5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.Lightup; + + /// + /// This class tests edge case behavior of in Roslyn 2+. It extends + /// since the tests defined there are valid in both environments without + /// alteration. + /// + public class LightupHelpersTestsCSharp7 : LightupHelpersTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..ca79c3f31 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ParenthesizedVariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.OpenParenToken); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.Variables); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.CloseParenToken); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithOpenParenToken(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithVariables(new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(SyntaxFactory.SeparatedList()))); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithCloseParenToken(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + } + + [Fact] + public void TestProperties() + { + var syntaxNode = SyntaxFactory.ParenthesizedVariableDesignation(); + Assert.True(syntaxNode.IsKind(SyntaxKind.ParenthesizedVariableDesignation)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.ParenthesizedVariableDesignation)); + + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.True(syntaxNode.OpenParenToken.IsEquivalentTo(parenthesizedVariableDesignationSyntax.OpenParenToken)); + + parenthesizedVariableDesignationSyntax = parenthesizedVariableDesignationSyntax.WithOpenParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.NotNull(parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.False(syntaxNode.OpenParenToken.IsEquivalentTo(parenthesizedVariableDesignationSyntax.OpenParenToken)); + Assert.True(syntaxNode.CloseParenToken.IsEquivalentTo(parenthesizedVariableDesignationSyntax.CloseParenToken)); + + var variables = SyntaxFactory.SingletonSeparatedList(SyntaxFactory.DiscardDesignation()); + parenthesizedVariableDesignationSyntax = parenthesizedVariableDesignationSyntax.WithVariables(new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(variables)); + Assert.Same( + ((ParenthesizedVariableDesignationSyntax)parenthesizedVariableDesignationSyntax.SyntaxNode).Variables[0], + parenthesizedVariableDesignationSyntax.Variables[0].SyntaxNode); + + parenthesizedVariableDesignationSyntax = parenthesizedVariableDesignationSyntax.WithCloseParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.NotNull(parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.False(syntaxNode.OpenParenToken.IsEquivalentTo(parenthesizedVariableDesignationSyntax.OpenParenToken)); + Assert.False(syntaxNode.CloseParenToken.IsEquivalentTo(parenthesizedVariableDesignationSyntax.CloseParenToken)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ParenthesizedVariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(ParenthesizedVariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.ParenthesizedVariableDesignation(); + Assert.True(ParenthesizedVariableDesignationSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = parenthesizedVariableDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(parenthesizedVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = parenthesizedVariableDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.ParenthesizedVariableDesignation(); + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = parenthesizedVariableDesignationSyntax; + Assert.Same(syntaxNode, variableDesignationSyntax.SyntaxNode); + + parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Same(syntaxNode, parenthesizedVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = parenthesizedVariableDesignationSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..76c46c77b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs @@ -0,0 +1,72 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class PatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + Assert.Null(patternSyntax.SyntaxNode); + } + + [Fact] + public void TestNonNull() + { + var syntaxNode = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, patternSyntax.SyntaxNode); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(PatternSyntaxWrapper.IsInstance(null)); + Assert.False(PatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var constantPatternSyntax = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.True(PatternSyntaxWrapper.IsInstance(constantPatternSyntax)); + + var declarationPatternSyntax = SyntaxFactory.DeclarationPattern( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.DiscardDesignation()); + Assert.True(PatternSyntaxWrapper.IsInstance(declarationPatternSyntax)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (PatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..2ed431b56 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,92 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SingleVariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(singleVariableDesignationSyntax.SyntaxNode); + Assert.Throws(() => singleVariableDesignationSyntax.Identifier); + Assert.Throws(() => singleVariableDesignationSyntax.WithIdentifier(SyntaxFactory.Identifier("Anything"))); + } + + [Fact] + public void TestIdentifier() + { + var syntaxNode = SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("Anything")); + Assert.True(syntaxNode.IsKind(SyntaxKind.SingleVariableDesignation)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.SingleVariableDesignation)); + + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, singleVariableDesignationSyntax.SyntaxNode); + Assert.Equal(syntaxNode.Identifier, singleVariableDesignationSyntax.Identifier); + + singleVariableDesignationSyntax = singleVariableDesignationSyntax.WithIdentifier(SyntaxFactory.Identifier("AnythingElse")); + Assert.NotNull(singleVariableDesignationSyntax.SyntaxNode); + Assert.NotSame(syntaxNode, singleVariableDesignationSyntax.SyntaxNode); + Assert.False(syntaxNode.Identifier.IsEquivalentTo(singleVariableDesignationSyntax.Identifier)); + Assert.Equal("AnythingElse", singleVariableDesignationSyntax.Identifier.ValueText); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(SingleVariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(SingleVariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("Anything")); + Assert.True(SingleVariableDesignationSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = singleVariableDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(singleVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = singleVariableDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("Anything")); + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = singleVariableDesignationSyntax; + Assert.Same(syntaxNode, variableDesignationSyntax.SyntaxNode); + + singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Same(syntaxNode, singleVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = singleVariableDesignationSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (SingleVariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs new file mode 100644 index 000000000..d4ad25f83 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SyntaxWrapperTests + { + [Fact] + public void TestWrapSyntaxNode() + { + SyntaxNode syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + + Assert.Same(syntaxNode, SyntaxWrapper.Default.Wrap(syntaxNode)); + Assert.Same(syntaxNode, SyntaxWrapper.Default.Unwrap((LiteralExpressionSyntax)syntaxNode)); + } + + [Fact] + public void TestWrapSyntaxWrapperNode() + { + var syntaxNode = SyntaxFactory.DiscardDesignation(); + var syntaxWrapper = SyntaxWrapper.Default; + + Assert.Same(syntaxNode, syntaxWrapper.Wrap(syntaxNode).SyntaxNode); + Assert.Same(syntaxNode, syntaxWrapper.Unwrap((DiscardDesignationSyntaxWrapper)syntaxNode)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..b3ec13804 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,67 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class VariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(patternSyntax.SyntaxNode); + } + + [Fact] + public void TestNonNull() + { + var syntaxNode = SyntaxFactory.DiscardDesignation(); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, patternSyntax.SyntaxNode); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(VariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(VariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var discardDesignationSyntax = SyntaxFactory.DiscardDesignation(); + Assert.True(VariableDesignationSyntaxWrapper.IsInstance(discardDesignationSyntax)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = SyntaxFactory.DiscardDesignation(); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (VariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..80ee7ce0e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs @@ -0,0 +1,41 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using Xunit; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("StyleCop.Analyzers.Test.CSharp7")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Tunnel Vision Laboratories, LLC")] +[assembly: AssemblyProduct("StyleCop.Analyzers.Test.CSharp7")] +[assembly: AssemblyCopyright("Copyright © Sam Harwell 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0-dev")] + +[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj new file mode 100644 index 000000000..3a86cc4f3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj @@ -0,0 +1,267 @@ + + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {F10E4AEF-86A2-4394-8B6F-1A3468B72F1D} + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + StyleCop.Analyzers.Test.CSharp7 + StyleCop.Analyzers.Test.CSharp7 + v4.6 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + $(OutputPath)$(AssemblyName).xml + ..\StyleCop.Analyzers.Internal.ruleset + + + true + ..\..\build\keys\TestingKey.snk + + + + ..\..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.Common.2.1.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.CSharp.2.1.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.1.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6\lib\net46\Microsoft.CodeAnalysis.Elfie.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.1.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.1.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll + True + + + + ..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + True + + + ..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + + + ..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + + + + ..\..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + + + ..\..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + True + + + ..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + + + ..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + + + ..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + + ..\..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll + True + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll + True + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll + True + + + ..\..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll + True + + + ..\..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + True + + + ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + True + + + + + + + + ..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + + + ..\..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + True + + + ..\..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + True + + + ..\..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + True + + + ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\net45\xunit.core.dll + True + + + ..\..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\net45\xunit.execution.desktop.dll + True + + + + + + + + + + + + + + + + + + + + + + TestingKey.snk + + + StyleCop.Analyzers.Internal.ruleset + + + StyleCop.Analyzers.ruleset + + + + + + + stylecop.json + + + + + {f91f7815-4e63-4698-b053-e57b2d707194} + StyleCop.Analyzers.CodeFixes + + + {3eb54b68-a7aa-45e8-a97b-a0746712140b} + StyleCop.Analyzers.Test + + + {3B052737-06CE-4182-AE0F-08EB82DFA73E} + StyleCop.Analyzers + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/app.config b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/app.config new file mode 100644 index 000000000..b6f489a10 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/app.config @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/packages.config b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/packages.config new file mode 100644 index 000000000..7ffd300b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/packages.config @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..268a9d5f3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,34 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class AccessorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestExpressionBody() + { + var accessorDeclarationSyntax = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); + Assert.Null(AccessorDeclarationSyntaxExtensions.ExpressionBody(accessorDeclarationSyntax)); + } + + [Fact] + public void TestWithExpressionBody() + { + var accessorDeclarationSyntax = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); + + // With default value is allowed + var accessorWithDefaultBody = AccessorDeclarationSyntaxExtensions.WithExpressionBody(accessorDeclarationSyntax, null); + Assert.Null(AccessorDeclarationSyntaxExtensions.ExpressionBody(accessorWithDefaultBody)); + + // Non-default throws an exception + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.Throws(() => AccessorDeclarationSyntaxExtensions.WithExpressionBody(accessorDeclarationSyntax, expressionBody)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs new file mode 100644 index 000000000..4f4f27372 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs @@ -0,0 +1,24 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + + public class AutoWrapSeparatedSyntaxListTests : SeparatedSyntaxListWrapperTestBase + { + internal override SeparatedSyntaxListWrapper CreateList() + { + return new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(default(SeparatedSyntaxList)); + } + + internal override bool TryCreateNonEmptyList(out SeparatedSyntaxListWrapper list) + { + list = new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList( + SyntaxFactory.SingletonSeparatedList(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + return true; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..a190f596d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class BaseMethodDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestExpressionBody_Constructor() + { + var syntax = SyntaxFactory.ConstructorDeclaration(SyntaxFactory.Identifier("Anything")); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + } + + [Fact] + public void TestExpressionBody_Destructor() + { + var syntax = SyntaxFactory.DestructorDeclaration(SyntaxFactory.Identifier("Anything")); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + } + + [Fact] + public void TestExpressionBody_Operator() + { + var syntax = SyntaxFactory.OperatorDeclaration( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.Token(SyntaxKind.PlusToken)); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + syntax = syntax.WithExpressionBody(expressionBody); + Assert.NotNull(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + Assert.Equal(SyntaxKind.NullLiteralExpression, BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax).Expression.Kind()); + } + + [Fact] + public void TestExpressionBody_ConversionOperator() + { + var syntax = SyntaxFactory.ConversionOperatorDeclaration( + SyntaxFactory.Token(SyntaxKind.ExplicitKeyword), + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + syntax = syntax.WithExpressionBody(expressionBody); + Assert.NotNull(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + Assert.Equal(SyntaxKind.NullLiteralExpression, BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax).Expression.Kind()); + } + + [Fact] + public void TestExpressionBody_Method() + { + var syntax = SyntaxFactory.MethodDeclaration( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + SyntaxFactory.Identifier("Anything")); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + syntax = syntax.WithExpressionBody(expressionBody); + Assert.NotNull(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax)); + Assert.Equal(SyntaxKind.NullLiteralExpression, BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntax).Expression.Kind()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..c3d239ac2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ConstantPatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + Assert.Null(constantPatternSyntax.SyntaxNode); + Assert.Throws(() => constantPatternSyntax.Expression); + Assert.Throws(() => constantPatternSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ConstantPatternSyntaxWrapper.IsInstance(null)); + Assert.False(ConstantPatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var constantPatternSyntax = (ConstantPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = constantPatternSyntax; + Assert.Null(patternSyntax.SyntaxNode); + + constantPatternSyntax = (ConstantPatternSyntaxWrapper)patternSyntax; + Assert.Null(constantPatternSyntax.SyntaxNode); + + SyntaxNode syntax = constantPatternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ConstantPatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..ecfc4a69d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,27 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ConstructorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestWithExpressionBody() + { + var syntax = SyntaxFactory.ConstructorDeclaration(SyntaxFactory.Identifier("Anything")); + + // With default value is allowed + var syntaxWithDefaultBody = ConstructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, null); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntaxWithDefaultBody)); + + // Non-default throws an exception + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.Throws(() => ConstructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, expressionBody)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..2ac427edd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DeclarationPatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + Assert.Null(declarationPatternSyntax.SyntaxNode); + Assert.Throws(() => declarationPatternSyntax.Type); + Assert.Throws(() => declarationPatternSyntax.Designation); + Assert.Throws(() => declarationPatternSyntax.WithType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)))); + Assert.Throws(() => declarationPatternSyntax.WithDesignation((VariableDesignationSyntaxWrapper)null)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(DeclarationPatternSyntaxWrapper.IsInstance(null)); + Assert.False(DeclarationPatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)syntaxNode; + + PatternSyntaxWrapper patternSyntax = declarationPatternSyntax; + Assert.Null(patternSyntax.SyntaxNode); + + declarationPatternSyntax = (DeclarationPatternSyntaxWrapper)patternSyntax; + Assert.Null(declarationPatternSyntax.SyntaxNode); + + SyntaxNode syntax = declarationPatternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (DeclarationPatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs new file mode 100644 index 000000000..181c0df4a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs @@ -0,0 +1,27 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DestructorDeclarationSyntaxExtensionsTests + { + [Fact] + public void TestWithExpressionBody() + { + var syntax = SyntaxFactory.DestructorDeclaration(SyntaxFactory.Identifier("Anything")); + + // With default value is allowed + var syntaxWithDefaultBody = DestructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, null); + Assert.Null(BaseMethodDeclarationSyntaxExtensions.ExpressionBody(syntaxWithDefaultBody)); + + // Non-default throws an exception + var expressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.Throws(() => DestructorDeclarationSyntaxExtensions.WithExpressionBody(syntax, expressionBody)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..343dbb9d7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class DiscardDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + Assert.Null(discardDesignationSyntax.SyntaxNode); + Assert.Throws(() => discardDesignationSyntax.UnderscoreToken); + Assert.Throws(() => discardDesignationSyntax.WithUnderscoreToken(SyntaxFactory.Token(SyntaxKindEx.UnderscoreToken))); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(DiscardDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(DiscardDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = discardDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + discardDesignationSyntax = (DiscardDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(discardDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = discardDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (DiscardDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs new file mode 100644 index 000000000..ef47f24f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class IsPatternExpressionSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + Assert.Null(isPatternExpressionSyntax.SyntaxNode); + Assert.Throws(() => isPatternExpressionSyntax.Expression); + Assert.Throws(() => isPatternExpressionSyntax.IsKeyword); + Assert.Throws(() => isPatternExpressionSyntax.Pattern); + Assert.Throws(() => isPatternExpressionSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => isPatternExpressionSyntax.WithIsKeyword(SyntaxFactory.Token(SyntaxKind.IsKeyword))); + Assert.Throws(() => isPatternExpressionSyntax.WithPattern((PatternSyntaxWrapper)null)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(IsPatternExpressionSyntaxWrapper.IsInstance(null)); + Assert.False(IsPatternExpressionSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var isPatternExpressionSyntax = (IsPatternExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = isPatternExpressionSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (IsPatternExpressionSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs new file mode 100644 index 000000000..600e11185 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs @@ -0,0 +1,109 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class LightupHelpersTests + { + [Fact] + public void TestCanWrapNullNode() + { + Assert.True(LightupHelpers.CanWrapNode(null, typeof(PatternSyntaxWrapper))); + } + + [Fact] + public void TestCanAccessNonExistentProperty() + { + var propertyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(SyntaxNode), "NonExistentProperty"); + Assert.NotNull(propertyAccessor); + Assert.Null(propertyAccessor(SyntaxFactory.AccessorList())); + Assert.Throws(() => propertyAccessor(null)); + + var withPropertyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(SyntaxNode), "NonExistentProperty"); + Assert.NotNull(withPropertyAccessor); + Assert.NotNull(withPropertyAccessor(SyntaxFactory.AccessorList(), null)); + Assert.ThrowsAny(() => withPropertyAccessor(SyntaxFactory.AccessorList(), new object())); + Assert.Throws(() => withPropertyAccessor(null, new object())); + + var separatedListPropertyAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(typeof(SyntaxNode), "NonExistentProperty"); + Assert.NotNull(separatedListPropertyAccessor); + Assert.NotNull(separatedListPropertyAccessor(SyntaxFactory.AccessorList())); + Assert.Throws(() => separatedListPropertyAccessor(null)); + + var separatedListWithPropertyAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(typeof(SyntaxNode), "NonExistentProperty"); + Assert.NotNull(separatedListWithPropertyAccessor); + Assert.NotNull(separatedListWithPropertyAccessor(SyntaxFactory.AccessorList(), null)); + Assert.ThrowsAny(() => separatedListWithPropertyAccessor(SyntaxFactory.AccessorList(), new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))))); + Assert.Throws(() => separatedListWithPropertyAccessor(null, SeparatedSyntaxListWrapper.UnsupportedEmpty)); + } + + [Fact] + public void TestCreateSyntaxPropertyAccessor() + { + // The call *should* have been made with the first generic argument set to `BaseMethodDeclarationSyntax` + // instead of `MethodDeclarationSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSyntaxPropertyAccessor(typeof(BaseMethodDeclarationSyntax), nameof(BaseMethodDeclarationSyntax.Body))); + + // The call *should* have been made with the second generic argument set to `ArrowExpressionClauseSyntax` + // instead of `BlockSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSyntaxPropertyAccessor(typeof(MethodDeclarationSyntax), nameof(MethodDeclarationSyntax.ExpressionBody))); + } + + [Fact] + public void TestCreateSeparatedSyntaxListPropertyAccessor() + { + // The call works for `SeparatedSyntaxList`, not work for `SyntaxList`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(typeof(BlockSyntax), nameof(BlockSyntax.Statements))); + + // The call *should* have been made with the first generic argument set to `BaseParameterListSyntax` + // instead of `ParameterListSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters))); + } + + [Fact(Skip = "Validation is not currently performed for the second argument.")] + public void TestCreateSeparatedSyntaxListPropertyAccessorValidateElementType() + { + // The call *should* have been made with the second generic argument set to `ParameterSyntax` + // instead of `ArgumentSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters))); + } + + [Fact] + public void TestCreateSyntaxWithPropertyAccessor() + { + // The call *should* have been made with the first generic argument set to `BaseMethodDeclarationSyntax` + // instead of `MethodDeclarationSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(BaseMethodDeclarationSyntax), nameof(BaseMethodDeclarationSyntax.Body))); + + // The call *should* have been made with the second generic argument set to `ArrowExpressionClauseSyntax` + // instead of `BlockSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(MethodDeclarationSyntax), nameof(MethodDeclarationSyntax.ExpressionBody))); + } + + [Fact] + public void TestCreateSeparatedSyntaxListWithPropertyAccessor() + { + // The call works for `SeparatedSyntaxList`, not work for `SyntaxList`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(typeof(BlockSyntax), nameof(BlockSyntax.Statements))); + + // The call *should* have been made with the first generic argument set to `BaseParameterListSyntax` + // instead of `ParameterListSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters))); + } + + [Fact(Skip = "Validation is not currently performed for the second argument.")] + public void TestCreateSeparatedSyntaxListWithPropertyAccessorValidateElementType() + { + // The call *should* have been made with the second generic argument set to `ParameterSyntax` + // instead of `ArgumentSyntax`. + Assert.ThrowsAny(() => LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..9bff6cb91 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ParenthesizedVariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(parenthesizedVariableDesignationSyntax.SyntaxNode); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.OpenParenToken); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.Variables); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.CloseParenToken); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithOpenParenToken(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithVariables(SeparatedSyntaxListWrapper.UnsupportedEmpty)); + Assert.Throws(() => parenthesizedVariableDesignationSyntax.WithCloseParenToken(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ParenthesizedVariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(ParenthesizedVariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = parenthesizedVariableDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + parenthesizedVariableDesignationSyntax = (ParenthesizedVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(parenthesizedVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = parenthesizedVariableDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ParenthesizedVariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs new file mode 100644 index 000000000..3b0725776 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class PatternSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + Assert.Null(patternSyntax.SyntaxNode); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(PatternSyntaxWrapper.IsInstance(null)); + Assert.False(PatternSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (PatternSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (PatternSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs new file mode 100644 index 000000000..3650ba4d2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public abstract class SeparatedSyntaxListWrapperTestBase + { + [Fact] + public void TestBasicProperties() + { + var list = this.CreateList(); + Assert.Equal(0, list.Count); + Assert.Equal(0, list.SeparatorCount); + Assert.Equal(default(SeparatedSyntaxList).FullSpan, list.FullSpan); + Assert.Equal(default(SeparatedSyntaxList).Span, list.Span); + Assert.Equal(default(SeparatedSyntaxList).ToString(), list.ToString()); + Assert.Equal(default(SeparatedSyntaxList).ToFullString(), list.ToFullString()); + Assert.ThrowsAny(() => list[0]); + + if (list.UnderlyingList != null) + { + Assert.IsAssignableFrom(typeof(SeparatedSyntaxList), list.UnderlyingList); + var underlyingList = (SeparatedSyntaxList)list.UnderlyingList; + Assert.Equal(0, list.Count); + } + } + + [Fact] + public void TestElements() + { + var list = this.CreateList(); + Assert.False(list.Any()); + Assert.Null(list.FirstOrDefault()); + Assert.Null(list.LastOrDefault()); + Assert.ThrowsAny(() => list.First()); + Assert.ThrowsAny(() => list.Last()); + + if (this.TryCreateNonEmptyList(out list)) + { + Assert.True(list.Any()); + Assert.NotNull(list.First()); + Assert.NotNull(list.FirstOrDefault()); + Assert.NotNull(list.Last()); + Assert.NotNull(list.LastOrDefault()); + } + } + + internal abstract SeparatedSyntaxListWrapper CreateList(); + + internal abstract bool TryCreateNonEmptyList(out SeparatedSyntaxListWrapper list); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..7b92d8723 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SingleVariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(singleVariableDesignationSyntax.SyntaxNode); + Assert.Throws(() => singleVariableDesignationSyntax.Identifier); + Assert.Throws(() => singleVariableDesignationSyntax.WithIdentifier(SyntaxFactory.Identifier("Anything"))); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(SingleVariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(SingleVariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)syntaxNode; + + VariableDesignationSyntaxWrapper variableDesignationSyntax = singleVariableDesignationSyntax; + Assert.Null(variableDesignationSyntax.SyntaxNode); + + singleVariableDesignationSyntax = (SingleVariableDesignationSyntaxWrapper)variableDesignationSyntax; + Assert.Null(singleVariableDesignationSyntax.SyntaxNode); + + SyntaxNode syntax = singleVariableDesignationSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (SingleVariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs new file mode 100644 index 000000000..b3636a905 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SyntaxWrapperTests + { + [Fact] + public void TestWrapSyntaxNode() + { + SyntaxNode syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + + Assert.Same(syntaxNode, SyntaxWrapper.Default.Wrap(syntaxNode)); + Assert.Same(syntaxNode, SyntaxWrapper.Default.Unwrap((LiteralExpressionSyntax)syntaxNode)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs new file mode 100644 index 000000000..12c55ad5a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs @@ -0,0 +1,22 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.Lightup; + + public class UnsupportedSyntaxListTests : SeparatedSyntaxListWrapperTestBase + { + internal override SeparatedSyntaxListWrapper CreateList() + { + return SeparatedSyntaxListWrapper.UnsupportedEmpty; + } + + internal override bool TryCreateNonEmptyList(out SeparatedSyntaxListWrapper list) + { + list = null; + return false; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs new file mode 100644 index 000000000..9a84489ec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class VariableDesignationSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + Assert.Null(patternSyntax.SyntaxNode); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(VariableDesignationSyntaxWrapper.IsInstance(null)); + Assert.False(VariableDesignationSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var patternSyntax = (VariableDesignationSyntaxWrapper)syntaxNode; + + SyntaxNode syntax = patternSyntax; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (VariableDesignationSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs index 6e0817200..adbb59155 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Xunit; @@ -39,3 +40,5 @@ [assembly: AssemblyInformationalVersion("1.0.0.0-dev")] [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] + +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj index 7be6dbae2..2b8f5ab6d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj @@ -235,6 +235,23 @@ + + + + + + + + + + + + + + + + + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs new file mode 100644 index 000000000..53b395870 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs @@ -0,0 +1,30 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class AccessorDeclarationSyntaxExtensions + { + private static readonly Func ExpressionBodyAccessor; + private static readonly Func WithExpressionBodyAccessor; + + static AccessorDeclarationSyntaxExtensions() + { + ExpressionBodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(AccessorDeclarationSyntax), nameof(ExpressionBody)); + WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(AccessorDeclarationSyntax), nameof(ExpressionBody)); + } + + public static ArrowExpressionClauseSyntax ExpressionBody(this AccessorDeclarationSyntax syntax) + { + return ExpressionBodyAccessor(syntax); + } + + public static AccessorDeclarationSyntax WithExpressionBody(this AccessorDeclarationSyntax syntax, ArrowExpressionClauseSyntax expressionBody) + { + return WithExpressionBodyAccessor(syntax, expressionBody); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs new file mode 100644 index 000000000..d6bc3e948 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class BaseMethodDeclarationSyntaxExtensions + { + private static readonly Func ExpressionBodyAccessor; + + static BaseMethodDeclarationSyntaxExtensions() + { + ExpressionBodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(BaseMethodDeclarationSyntax), nameof(ExpressionBody)); + } + + public static ArrowExpressionClauseSyntax ExpressionBody(this BaseMethodDeclarationSyntax syntax) + { + if (!LightupHelpers.SupportsCSharp7) + { + // Prior to C# 7, the ExpressionBody properties did not override a base method. + switch (syntax.Kind()) + { + case SyntaxKind.MethodDeclaration: + return ((MethodDeclarationSyntax)syntax).ExpressionBody; + + case SyntaxKind.OperatorDeclaration: + return ((OperatorDeclarationSyntax)syntax).ExpressionBody; + + case SyntaxKind.ConversionOperatorDeclaration: + return ((ConversionOperatorDeclarationSyntax)syntax).ExpressionBody; + + default: + break; + } + } + + return ExpressionBodyAccessor(syntax); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md new file mode 100644 index 000000000..1237996bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md @@ -0,0 +1,440 @@ +# C# 7 APIs supported via light-up + +## Semantics + +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.DisplayVersion.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.EmbeddedFiles.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.SourceLink.get -> string` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateAnonymousTypeSymbol(System.Collections.Immutable.ImmutableArray memberTypes, System.Collections.Immutable.ImmutableArray memberNames, System.Collections.Immutable.ImmutableArray memberIsReadOnly = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray memberLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateErrorNamespaceSymbol(Microsoft.CodeAnalysis.INamespaceSymbol container, string name) -> Microsoft.CodeAnalysis.INamespaceSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(Microsoft.CodeAnalysis.INamedTypeSymbol underlyingType, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray elementTypes, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult` +* [ ] `Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, System.Collections.Generic.IEnumerable manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.Emit.EmitResult` +* [ ] `Microsoft.CodeAnalysis.Compilation.GetUnreferencedAssemblyIdentities(Microsoft.CodeAnalysis.Diagnostic diagnostic) -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithConcurrentBuild(bool concurrent) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithCryptoKeyContainer(string cryptoKeyContainer) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithCryptoKeyFile(string cryptoKeyFile) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithCryptoPublicKey(System.Collections.Immutable.ImmutableArray cryptoPublicKey) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithDelaySign(bool? delaySign) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithMainTypeName(string mainTypeName) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithModuleName(string moduleName) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithOverflowChecks(bool checkOverflow) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithScriptClassName(string scriptClassName) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.DesktopStrongNameProvider.DesktopStrongNameProvider(System.Collections.Immutable.ImmutableArray keyFileSearchPaths = default(System.Collections.Immutable.ImmutableArray), string tempPath = null) -> void` +* [ ] `Microsoft.CodeAnalysis.DesktopStrongNameProvider.DesktopStrongNameProvider(System.Collections.Immutable.ImmutableArray keyFileSearchPaths) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.AnalyzerTelemetryInfo() -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CodeBlockActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CodeBlockEndActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CodeBlockStartActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CompilationActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CompilationEndActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.CompilationStartActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.ExecutionTime.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockEndActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockEndActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SemanticModelActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SymbolActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SyntaxNodeActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SyntaxTreeActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.EmbeddedText` +* [ ] `Microsoft.CodeAnalysis.EmbeddedText.Checksum.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.EmbeddedText.ChecksumAlgorithm.get -> Microsoft.CodeAnalysis.Text.SourceHashAlgorithm` +* [ ] `Microsoft.CodeAnalysis.EmbeddedText.FilePath.get -> string` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = false, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat, string pdbFilePath, string outputNameOverride, int fileAlignment, ulong baseAddress, bool highEntropyVirtualAddressSpace, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion, string runtimeMetadataVersion, bool tolerateErrors, bool includePrivateMembers) -> void` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.InstrumentationKinds.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.WithInstrumentationKinds(System.Collections.Immutable.ImmutableArray instrumentationKinds) -> Microsoft.CodeAnalysis.Emit.EmitOptions` +* [ ] `Microsoft.CodeAnalysis.Emit.InstrumentationKind` +* [ ] `Microsoft.CodeAnalysis.Emit.InstrumentationKind.None = 0 -> Microsoft.CodeAnalysis.Emit.InstrumentationKind` +* [ ] `Microsoft.CodeAnalysis.Emit.InstrumentationKind.TestCoverage = 1 -> Microsoft.CodeAnalysis.Emit.InstrumentationKind` +* [ ] `Microsoft.CodeAnalysis.IArrayTypeSymbol.IsSZArray.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IArrayTypeSymbol.LowerBounds.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IArrayTypeSymbol.Sizes.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IDiscardSymbol` +* [ ] `Microsoft.CodeAnalysis.IDiscardSymbol.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.IFieldSymbol.CorrespondingTupleField.get -> Microsoft.CodeAnalysis.IFieldSymbol` +* [ ] `Microsoft.CodeAnalysis.ILocalSymbol.IsRef.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRef.get -> bool` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.GetTypeArgumentCustomModifiers(int ordinal) -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.IsComImport.get -> bool` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.TupleElements.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.TupleUnderlyingType.get -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.IParameterSymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IPropertySymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IPropertySymbol.ReturnsByRef.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.IsTupleType.get -> bool` +* [x] `Microsoft.CodeAnalysis.MethodKind.LocalFunction = 17 -> Microsoft.CodeAnalysis.MethodKind` +* [ ] `Microsoft.CodeAnalysis.PortableExecutableReference.GetMetadataId() -> Microsoft.CodeAnalysis.MetadataId` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayFormat.RemoveGenericsOptions(Microsoft.CodeAnalysis.SymbolDisplayGenericsOptions options) -> Microsoft.CodeAnalysis.SymbolDisplayFormat` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayFormat.RemoveLocalOptions(Microsoft.CodeAnalysis.SymbolDisplayLocalOptions options) -> Microsoft.CodeAnalysis.SymbolDisplayFormat` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayFormat.RemoveMiscellaneousOptions(Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions options) -> Microsoft.CodeAnalysis.SymbolDisplayFormat` +* [x] `Microsoft.CodeAnalysis.SymbolDisplayLocalOptions.IncludeRef = 4 -> Microsoft.CodeAnalysis.SymbolDisplayLocalOptions` +* [x] `Microsoft.CodeAnalysis.SymbolDisplayMemberOptions.IncludeRef = 128 -> Microsoft.CodeAnalysis.SymbolDisplayMemberOptions` +* [x] `Microsoft.CodeAnalysis.SymbolKind.Discard = 19 -> Microsoft.CodeAnalysis.SymbolKind` +* [ ] `Microsoft.CodeAnalysis.Text.SourceText.CanBeEmbedded.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Text.SourceText.GetChecksum() -> System.Collections.Immutable.ImmutableArray` +* [ ] `abstract Microsoft.CodeAnalysis.CompilationOptions.Language.get -> string` +* [ ] `abstract Microsoft.CodeAnalysis.ParseOptions.Language.get -> string` +* [x] ~~`override Microsoft.CodeAnalysis.SyntaxNode.ToString() -> string`~~ +* [ ] `static Microsoft.CodeAnalysis.CaseInsensitiveComparison.StartsWith(string value, string possibleStart) -> bool` +* [ ] `static Microsoft.CodeAnalysis.EmbeddedText.FromBytes(string filePath, System.ArraySegment bytes, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) -> Microsoft.CodeAnalysis.EmbeddedText` +* [ ] `static Microsoft.CodeAnalysis.EmbeddedText.FromSource(string filePath, Microsoft.CodeAnalysis.Text.SourceText text) -> Microsoft.CodeAnalysis.EmbeddedText` +* [ ] `static Microsoft.CodeAnalysis.EmbeddedText.FromStream(string filePath, System.IO.Stream stream, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) -> Microsoft.CodeAnalysis.EmbeddedText` +* [ ] `static Microsoft.CodeAnalysis.SeparatedSyntaxList.implicit operator Microsoft.CodeAnalysis.SeparatedSyntaxList(Microsoft.CodeAnalysis.SeparatedSyntaxList nodes) -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [ ] `static Microsoft.CodeAnalysis.SeparatedSyntaxList.implicit operator Microsoft.CodeAnalysis.SeparatedSyntaxList(Microsoft.CodeAnalysis.SeparatedSyntaxList nodes) -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [ ] `static Microsoft.CodeAnalysis.SyntaxNodeExtensions.WithoutTrivia(this Microsoft.CodeAnalysis.SyntaxToken token) -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `static Microsoft.CodeAnalysis.Text.SourceText.From(System.IO.Stream stream, System.Text.Encoding encoding = null, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false) -> Microsoft.CodeAnalysis.Text.SourceText` +* [ ] `static Microsoft.CodeAnalysis.Text.SourceText.From(System.IO.Stream stream, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) -> Microsoft.CodeAnalysis.Text.SourceText` +* [ ] `static Microsoft.CodeAnalysis.Text.SourceText.From(System.IO.TextReader reader, int length, System.Text.Encoding encoding = null, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) -> Microsoft.CodeAnalysis.Text.SourceText` +* [ ] `static Microsoft.CodeAnalysis.Text.SourceText.From(byte[] buffer, int length, System.Text.Encoding encoding = null, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false) -> Microsoft.CodeAnalysis.Text.SourceText` +* [ ] `static Microsoft.CodeAnalysis.Text.SourceText.From(byte[] buffer, int length, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) -> Microsoft.CodeAnalysis.Text.SourceText` +* [ ] `virtual Microsoft.CodeAnalysis.SymbolVisitor.VisitDiscard(Microsoft.CodeAnalysis.IDiscardSymbol symbol) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.SymbolVisitor.VisitDiscard(Microsoft.CodeAnalysis.IDiscardSymbol symbol) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxNode.ChildThatContainsPosition(int position) -> Microsoft.CodeAnalysis.SyntaxNodeOrToken` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxNode.SerializeTo(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxNode.ToFullString() -> string` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxNode.WriteTo(System.IO.TextWriter writer) -> void` + +## Syntax + +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.CSharpParseOptions(Microsoft.CodeAnalysis.CSharp.LanguageVersion languageVersion = Microsoft.CodeAnalysis.CSharp.LanguageVersion.Default, Microsoft.CodeAnalysis.DocumentationMode documentationMode = Microsoft.CodeAnalysis.DocumentationMode.Parse, Microsoft.CodeAnalysis.SourceCodeKind kind = Microsoft.CodeAnalysis.SourceCodeKind.Regular, System.Collections.Generic.IEnumerable preprocessorSymbols = null) -> void` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.SpecifiedLanguageVersion.get -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.IsThrow.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.IsTupleConversion.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.IsTupleLiteralConversion.get -> bool` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7 = 7 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.Default = 0 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.Latest = 2147483647 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken keyword, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax.WithExpressionBody(Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.Pattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken keyword, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.WhenClause.get -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.WithColonToken(Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.WithKeyword(Microsoft.CodeAnalysis.SyntaxToken keyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.WithPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.WithWhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorInitializerSyntax initializer, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax.WithExpressionBody(Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken tildeToken, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax.WithExpressionBody(Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax.UnderscoreToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax.WithUnderscoreToken(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Variable.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithForEachKeyword(Microsoft.CodeAnalysis.SyntaxToken forEachKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithInKeyword(Microsoft.CodeAnalysis.SyntaxToken inKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithVariable(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.IsKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.Pattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken isKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.WithIsKeyword(Microsoft.CodeAnalysis.SyntaxToken isKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.WithPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.AddBodyStatements(params Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.AddConstraintClauses(params Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterConstraintClauseSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.AddParameterListParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.AddTypeParameterListParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Body.get -> Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.ConstraintClauses.get -> Microsoft.CodeAnalysis.SyntaxList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Identifier.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.ParameterList.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.ReturnType.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.SemicolonToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.TypeParameterList.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax typeParameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.SyntaxList constraintClauses, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithBody(Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithConstraintClauses(Microsoft.CodeAnalysis.SyntaxList constraintClauses) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithExpressionBody(Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithReturnType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.WithTypeParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax typeParameterList) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.AddVariables(params Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList variables, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.Variables.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.WithVariables(Microsoft.CodeAnalysis.SeparatedSyntaxList variables) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.RefKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.WithRefKeyword(Microsoft.CodeAnalysis.SyntaxToken refKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.RefKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithRefKeyword(Microsoft.CodeAnalysis.SyntaxToken refKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax.Identifier.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.ThrowKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken throwKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.WithThrowKeyword(Microsoft.CodeAnalysis.SyntaxToken throwKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.Identifier.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.AddArguments(params Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.Arguments.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arguments, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.WithArguments(Microsoft.CodeAnalysis.SeparatedSyntaxList arguments) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.AddElements(params Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Elements.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList elements, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.WithElements(Microsoft.CodeAnalysis.SeparatedSyntaxList elements) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Condition.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken whenKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.WhenKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.WithCondition(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.WithWhenKeyword(Microsoft.CodeAnalysis.SyntaxToken whenKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.CasePatternSwitchLabel = 9009 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ConstantPattern = 9002 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DeclarationExpression = 9040 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DeclarationPattern = 9000 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DiscardDesignation = 9014 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ForEachVariableStatement = 8929 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.IsPatternExpression = 8657 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.LocalFunctionStatement = 8830 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ParenthesizedVariableDesignation = 8928 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.RefExpression = 9050 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.RefType = 9051 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.SingleVariableDesignation = 8927 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ThrowExpression = 9052 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.TupleElement = 8925 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.TupleExpression = 8926 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.TupleType = 8924 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.UnderscoreToken = 8491 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.WhenClause = 9013 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.ForEachKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.InKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.Statement.get -> Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.Language.get -> string` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.Language.get -> string` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitCasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitConstantPattern(Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDeclarationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDeclarationPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDiscardDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitForEachVariableStatement(Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitIsPatternExpression(Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitParenthesizedVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitRefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitRefType(Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitSingleVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitTupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitTupleExpression(Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitTupleType(Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitWhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.ColonToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax.Keyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.ForEachKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.InKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.Statement.get -> Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.ForEachKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.InKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Statement.get -> Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax.ExpressionBody.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax declaratorSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax designationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax declarationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax declaratorSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetForEachStatementInfo(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax forEachStatement) -> Microsoft.CodeAnalysis.CSharp.ForEachStatementInfo` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken keyword, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.AccessorDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken keyword, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.CasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.CasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.CasePatternSwitchLabel(Microsoft.CodeAnalysis.SyntaxToken keyword, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConstantPattern(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConstructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorInitializerSyntax initializer, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConstructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorInitializerSyntax initializer, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConstructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorInitializerSyntax initializer, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConstructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorInitializerSyntax initializer, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeclarationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeclarationPattern(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DestructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DestructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DestructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken tildeToken, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DestructorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken tildeToken, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DiscardDesignation() -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DiscardDesignation(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ForEachVariableStatement(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ForEachVariableStatement(Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.IsPatternExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.IsPatternExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken isKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.LocalFunctionStatement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType, Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.LocalFunctionStatement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType, string identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.LocalFunctionStatement(Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax typeParameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.SyntaxList constraintClauses, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.LocalFunctionStatement(Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax returnType, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax typeParameterList, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList, Microsoft.CodeAnalysis.SyntaxList constraintClauses, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParenthesizedVariableDesignation(Microsoft.CodeAnalysis.SeparatedSyntaxList variables = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParenthesizedVariableDesignation(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList variables, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SingleVariableDesignation(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.SyntaxToken throwKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SeparatedSyntaxList arguments = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arguments, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SeparatedSyntaxList elements = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList elements, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.WhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.WhenClause(Microsoft.CodeAnalysis.SyntaxToken whenKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitCasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitConstantPattern(Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDeclarationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDiscardDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitForEachVariableStatement(Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitIsPatternExpression(Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitParenthesizedVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRefType(Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSingleVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleExpression(Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleType(Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitWhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitCasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitConstantPattern(Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDeclarationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDiscardDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitForEachVariableStatement(Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitIsPatternExpression(Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitParenthesizedVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRefType(Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSingleVariableDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleExpression(Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitTupleType(Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitWhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax node) -> TResult` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs new file mode 100644 index 000000000..b839c03c4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs @@ -0,0 +1,105 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct CasePatternSwitchLabelSyntaxWrapper : ISyntaxWrapper + { + private const string CasePatternSwitchLabelSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax"; + private static readonly Type CasePatternSwitchLabelSyntaxType; + + private static readonly Func PatternAccessor; + private static readonly Func WhenClauseAccessor; + private static readonly Func WithKeywordAccessor; + private static readonly Func WithColonTokenAccessor; + private static readonly Func WithPatternAccessor; + private static readonly Func WithWhenClauseAccessor; + + private readonly SwitchLabelSyntax node; + + static CasePatternSwitchLabelSyntaxWrapper() + { + CasePatternSwitchLabelSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(CasePatternSwitchLabelSyntaxTypeName); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(Pattern)); + WhenClauseAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(WhenClause)); + WithKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(SwitchLabelSyntax.Keyword)); + WithColonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(SwitchLabelSyntax.ColonToken)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(Pattern)); + WithWhenClauseAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(CasePatternSwitchLabelSyntaxType, nameof(WhenClause)); + } + + private CasePatternSwitchLabelSyntaxWrapper(SwitchLabelSyntax node) + { + this.node = node; + } + + public SwitchLabelSyntax SyntaxNode => this.node; + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public WhenClauseSyntaxWrapper WhenClause + { + get + { + return (WhenClauseSyntaxWrapper)WhenClauseAccessor(this.SyntaxNode); + } + } + + public static explicit operator CasePatternSwitchLabelSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(CasePatternSwitchLabelSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{CasePatternSwitchLabelSyntaxTypeName}'"); + } + + return new CasePatternSwitchLabelSyntaxWrapper((SwitchLabelSyntax)node); + } + + public static implicit operator SwitchLabelSyntax(CasePatternSwitchLabelSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, CasePatternSwitchLabelSyntaxType); + } + + public CasePatternSwitchLabelSyntaxWrapper WithKeyword(SyntaxToken keyword) + { + return new CasePatternSwitchLabelSyntaxWrapper(WithKeywordAccessor(this.SyntaxNode, keyword)); + } + + public CasePatternSwitchLabelSyntaxWrapper WithColonToken(SyntaxToken colonToken) + { + return new CasePatternSwitchLabelSyntaxWrapper(WithColonTokenAccessor(this.SyntaxNode, colonToken)); + } + + public CasePatternSwitchLabelSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new CasePatternSwitchLabelSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); + } + + public CasePatternSwitchLabelSyntaxWrapper WithWhenClause(WhenClauseSyntaxWrapper whenClause) + { + return new CasePatternSwitchLabelSyntaxWrapper(WithWhenClauseAccessor(this.SyntaxNode, whenClause)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs new file mode 100644 index 000000000..c0cf8c680 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs @@ -0,0 +1,136 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct CommonForEachStatementSyntaxWrapper : ISyntaxWrapper + { + private const string CommonForEachStatementSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax"; + + /// + /// Prior to C# 7, was the base type for all foreach statements. If + /// the CommonForEachStatementSyntax type isn't found at runtime, we fall back to using this type + /// instead. + /// + private const string ForEachStatementSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax"; + + private static readonly Type CommonForEachStatementSyntaxType; + + private static readonly Func ForEachKeywordAccessor; + private static readonly Func OpenParenTokenAccessor; + private static readonly Func InKeywordAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func StatementAccessor; + + private readonly StatementSyntax node; + + static CommonForEachStatementSyntaxWrapper() + { + CommonForEachStatementSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(CommonForEachStatementSyntaxTypeName) + ?? typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(ForEachStatementSyntaxTypeName); + ForEachKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(ForEachKeyword)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(OpenParenToken)); + InKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(InKeyword)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(Expression)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(CloseParenToken)); + StatementAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(CommonForEachStatementSyntaxType, nameof(Statement)); + } + + private CommonForEachStatementSyntaxWrapper(StatementSyntax node) + { + this.node = node; + } + + public StatementSyntax SyntaxNode => this.node; + + public SyntaxToken ForEachKeyword + { + get + { + return ForEachKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken InKeyword + { + get + { + return InKeywordAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public StatementSyntax Statement + { + get + { + return StatementAccessor(this.SyntaxNode); + } + } + + public static implicit operator CommonForEachStatementSyntaxWrapper(ForEachStatementSyntax node) + { + return new CommonForEachStatementSyntaxWrapper(node); + } + + public static explicit operator CommonForEachStatementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(CommonForEachStatementSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{CommonForEachStatementSyntaxTypeName}'"); + } + + return new CommonForEachStatementSyntaxWrapper((StatementSyntax)node); + } + + public static implicit operator StatementSyntax(CommonForEachStatementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, CommonForEachStatementSyntaxType); + } + + internal static CommonForEachStatementSyntaxWrapper FromUpcast(StatementSyntax node) + { + return new CommonForEachStatementSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs new file mode 100644 index 000000000..687a0f0ea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs @@ -0,0 +1,84 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct ConstantPatternSyntaxWrapper : ISyntaxWrapper + { + private const string ConstantPatternSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax"; + private static readonly Type ConstantPatternSyntaxType; + + private static readonly Func ExpressionAccessor; + private static readonly Func WithExpressionAccessor; + + private readonly CSharpSyntaxNode node; + + static ConstantPatternSyntaxWrapper() + { + ConstantPatternSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(ConstantPatternSyntaxTypeName); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ConstantPatternSyntaxType, nameof(Expression)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ConstantPatternSyntaxType, nameof(Expression)); + } + + private ConstantPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public static explicit operator ConstantPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (ConstantPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ConstantPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(ConstantPatternSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{ConstantPatternSyntaxTypeName}'"); + } + + return new ConstantPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(ConstantPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(ConstantPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, ConstantPatternSyntaxType); + } + + public ConstantPatternSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new ConstantPatternSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs new file mode 100644 index 000000000..0f6d8f579 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class ConstructorDeclarationSyntaxExtensions + { + private static readonly Func WithExpressionBodyAccessor; + + static ConstructorDeclarationSyntaxExtensions() + { + WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(ConstructorDeclarationSyntax), nameof(BaseMethodDeclarationSyntaxExtensions.ExpressionBody)); + } + + public static ConstructorDeclarationSyntax WithExpressionBody(this ConstructorDeclarationSyntax syntax, ArrowExpressionClauseSyntax expressionBody) + { + return WithExpressionBodyAccessor(syntax, expressionBody); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..ae724b1b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct DeclarationExpressionSyntaxWrapper : ISyntaxWrapper + { + private const string DeclarationExpressionSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax"; + private static readonly Type DeclarationExpressionSyntaxType; + + private static readonly Func TypeAccessor; + private static readonly Func DesignationAccessor; + private static readonly Func WithTypeAccessor; + private static readonly Func WithDesignationAccessor; + + private readonly ExpressionSyntax node; + + static DeclarationExpressionSyntaxWrapper() + { + DeclarationExpressionSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(DeclarationExpressionSyntaxTypeName); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(DeclarationExpressionSyntaxType, nameof(Type)); + DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(DeclarationExpressionSyntaxType, nameof(Designation)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(DeclarationExpressionSyntaxType, nameof(Type)); + WithDesignationAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(DeclarationExpressionSyntaxType, nameof(Designation)); + } + + private DeclarationExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public VariableDesignationSyntaxWrapper Designation + { + get + { + return (VariableDesignationSyntaxWrapper)DesignationAccessor(this.SyntaxNode); + } + } + + public static explicit operator DeclarationExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(DeclarationExpressionSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{DeclarationExpressionSyntaxTypeName}'"); + } + + return new DeclarationExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(DeclarationExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, DeclarationExpressionSyntaxType); + } + + public DeclarationExpressionSyntaxWrapper WithType(TypeSyntax type) + { + return new DeclarationExpressionSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + + public DeclarationExpressionSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) + { + return new DeclarationExpressionSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation.SyntaxNode)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs new file mode 100644 index 000000000..0aa8657fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs @@ -0,0 +1,101 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct DeclarationPatternSyntaxWrapper : ISyntaxWrapper + { + private const string DeclarationPatternSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax"; + private static readonly Type DeclarationPatternSyntaxType; + + private static readonly Func TypeAccessor; + private static readonly Func DesignationAccessor; + private static readonly Func WithTypeAccessor; + private static readonly Func WithDesignationAccessor; + + private readonly CSharpSyntaxNode node; + + static DeclarationPatternSyntaxWrapper() + { + DeclarationPatternSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(DeclarationPatternSyntaxTypeName); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(DeclarationPatternSyntaxType, nameof(Type)); + DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(DeclarationPatternSyntaxType, nameof(Designation)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(DeclarationPatternSyntaxType, nameof(Type)); + WithDesignationAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(DeclarationPatternSyntaxType, nameof(Designation)); + } + + private DeclarationPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public VariableDesignationSyntaxWrapper Designation + { + get + { + return (VariableDesignationSyntaxWrapper)DesignationAccessor(this.SyntaxNode); + } + } + + public static explicit operator DeclarationPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (DeclarationPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator DeclarationPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(DeclarationPatternSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{DeclarationPatternSyntaxTypeName}'"); + } + + return new DeclarationPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(DeclarationPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(DeclarationPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, DeclarationPatternSyntaxType); + } + + public DeclarationPatternSyntaxWrapper WithType(TypeSyntax type) + { + return new DeclarationPatternSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + + public DeclarationPatternSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) + { + return new DeclarationPatternSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation.SyntaxNode)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs new file mode 100644 index 000000000..91d67109f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class DestructorDeclarationSyntaxExtensions + { + private static readonly Func WithExpressionBodyAccessor; + + static DestructorDeclarationSyntaxExtensions() + { + WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(DestructorDeclarationSyntax), nameof(BaseMethodDeclarationSyntaxExtensions.ExpressionBody)); + } + + public static DestructorDeclarationSyntax WithExpressionBody(this DestructorDeclarationSyntax syntax, ArrowExpressionClauseSyntax expressionBody) + { + return WithExpressionBodyAccessor(syntax, expressionBody); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs new file mode 100644 index 000000000..4f36d786f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs @@ -0,0 +1,83 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal struct DiscardDesignationSyntaxWrapper : ISyntaxWrapper + { + private const string DiscardDesignationSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax"; + private static readonly Type DiscardDesignationSyntaxType; + + private static readonly Func UnderscoreTokenAccessor; + private static readonly Func WithUnderscoreTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static DiscardDesignationSyntaxWrapper() + { + DiscardDesignationSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(DiscardDesignationSyntaxTypeName); + UnderscoreTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(DiscardDesignationSyntaxType, nameof(UnderscoreToken)); + WithUnderscoreTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(DiscardDesignationSyntaxType, nameof(UnderscoreToken)); + } + + private DiscardDesignationSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken UnderscoreToken + { + get + { + return UnderscoreTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator DiscardDesignationSyntaxWrapper(VariableDesignationSyntaxWrapper node) + { + return (DiscardDesignationSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator DiscardDesignationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(DiscardDesignationSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{DiscardDesignationSyntaxTypeName}'"); + } + + return new DiscardDesignationSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator VariableDesignationSyntaxWrapper(DiscardDesignationSyntaxWrapper wrapper) + { + return VariableDesignationSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(DiscardDesignationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, DiscardDesignationSyntaxType); + } + + public DiscardDesignationSyntaxWrapper WithUnderscoreToken(SyntaxToken identifier) + { + return new DiscardDesignationSyntaxWrapper(WithUnderscoreTokenAccessor(this.SyntaxNode, identifier)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs new file mode 100644 index 000000000..823a0503f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs @@ -0,0 +1,174 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct ForEachVariableStatementSyntaxWrapper : ISyntaxWrapper + { + private const string ForEachVariableStatementSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax"; + private static readonly Type ForEachVariableStatementSyntaxType; + + private static readonly Func VariableAccessor; + private static readonly Func WithForEachKeywordAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func WithVariableAccessor; + private static readonly Func WithInKeywordAccessor; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithCloseParenTokenAccessor; + private static readonly Func WithStatementAccessor; + + private readonly StatementSyntax node; + + static ForEachVariableStatementSyntaxWrapper() + { + ForEachVariableStatementSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(ForEachVariableStatementSyntaxTypeName); + VariableAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(Variable)); + WithForEachKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(ForEachKeyword)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(OpenParenToken)); + WithVariableAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(Variable)); + WithInKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(InKeyword)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(Expression)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(CloseParenToken)); + WithStatementAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ForEachVariableStatementSyntaxType, nameof(Statement)); + } + + private ForEachVariableStatementSyntaxWrapper(StatementSyntax node) + { + this.node = node; + } + + public StatementSyntax SyntaxNode => this.node; + + public SyntaxToken ForEachKeyword + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).ForEachKeyword; + } + } + + public SyntaxToken OpenParenToken + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).OpenParenToken; + } + } + + public ExpressionSyntax Variable + { + get + { + return VariableAccessor(this.SyntaxNode); + } + } + + public SyntaxToken InKeyword + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).InKeyword; + } + } + + public ExpressionSyntax Expression + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).Expression; + } + } + + public SyntaxToken CloseParenToken + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).CloseParenToken; + } + } + + public StatementSyntax Statement + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).Statement; + } + } + + public static explicit operator ForEachVariableStatementSyntaxWrapper(CommonForEachStatementSyntaxWrapper node) + { + return (ForEachVariableStatementSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ForEachVariableStatementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(ForEachVariableStatementSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{ForEachVariableStatementSyntaxTypeName}'"); + } + + return new ForEachVariableStatementSyntaxWrapper((StatementSyntax)node); + } + + public static implicit operator CommonForEachStatementSyntaxWrapper(ForEachVariableStatementSyntaxWrapper wrapper) + { + return CommonForEachStatementSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator StatementSyntax(ForEachVariableStatementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, ForEachVariableStatementSyntaxType); + } + + public ForEachVariableStatementSyntaxWrapper WithForEachKeyword(SyntaxToken forEachKeyword) + { + return new ForEachVariableStatementSyntaxWrapper(WithForEachKeywordAccessor(this.SyntaxNode, forEachKeyword)); + } + + public ForEachVariableStatementSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new ForEachVariableStatementSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public ForEachVariableStatementSyntaxWrapper WithVariable(ExpressionSyntax variable) + { + return new ForEachVariableStatementSyntaxWrapper(WithVariableAccessor(this.SyntaxNode, variable)); + } + + public ForEachVariableStatementSyntaxWrapper WithInKeyword(SyntaxToken inKeyword) + { + return new ForEachVariableStatementSyntaxWrapper(WithInKeywordAccessor(this.SyntaxNode, inKeyword)); + } + + public ForEachVariableStatementSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new ForEachVariableStatementSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public ForEachVariableStatementSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new ForEachVariableStatementSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + + public ForEachVariableStatementSyntaxWrapper WithStatement(StatementSyntax statement) + { + return new ForEachVariableStatementSyntaxWrapper(WithStatementAccessor(this.SyntaxNode, statement)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs new file mode 100644 index 000000000..77991cd3b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs @@ -0,0 +1,26 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + /// + /// Represents a light-up wrapper for a type derived from a known back syntax kind . + /// + /// The base syntax kind which is exposed in the referenced API. + internal interface ISyntaxWrapper + where T : SyntaxNode + { + /// + /// Gets the wrapped syntax node. + /// + /// + /// The wrapped syntax node. + /// + T SyntaxNode + { + get; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..01f98356c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct IsPatternExpressionSyntaxWrapper : ISyntaxWrapper + { + private const string IsPatternExpressionSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax"; + private static readonly Type IsPatternExpressionSyntaxType; + + private static readonly Func ExpressionAccessor; + private static readonly Func IsKeywordAccessor; + private static readonly Func PatternAccessor; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithIsKeywordAccessor; + private static readonly Func WithPatternAccessor; + + private readonly ExpressionSyntax node; + + static IsPatternExpressionSyntaxWrapper() + { + IsPatternExpressionSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(IsPatternExpressionSyntaxTypeName); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(IsPatternExpressionSyntaxType, nameof(Expression)); + IsKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(IsPatternExpressionSyntaxType, nameof(IsKeyword)); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(IsPatternExpressionSyntaxType, nameof(Pattern)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(IsPatternExpressionSyntaxType, nameof(Expression)); + WithIsKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(IsPatternExpressionSyntaxType, nameof(IsKeyword)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(IsPatternExpressionSyntaxType, nameof(Pattern)); + } + + private IsPatternExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken IsKeyword + { + get + { + return IsKeywordAccessor(this.SyntaxNode); + } + } + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public static explicit operator IsPatternExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(IsPatternExpressionSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{IsPatternExpressionSyntaxTypeName}'"); + } + + return new IsPatternExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(IsPatternExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, IsPatternExpressionSyntaxType); + } + + public IsPatternExpressionSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new IsPatternExpressionSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public IsPatternExpressionSyntaxWrapper WithIsKeyword(SyntaxToken isKeyword) + { + return new IsPatternExpressionSyntaxWrapper(WithIsKeywordAccessor(this.SyntaxNode, isKeyword)); + } + + public IsPatternExpressionSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new IsPatternExpressionSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern.SyntaxNode)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs new file mode 100644 index 000000000..3c30145b5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs @@ -0,0 +1,14 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + + internal static class LanguageVersionEx + { + public const LanguageVersion Default = 0; + public const LanguageVersion CSharp7 = (LanguageVersion)7; + public const LanguageVersion Latest = (LanguageVersion)int.MaxValue; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs new file mode 100644 index 000000000..9ff9d1b6b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs @@ -0,0 +1,284 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Concurrent; + using System.Linq; + using System.Linq.Expressions; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal static class LightupHelpers + { + private static readonly ConcurrentDictionary> SupportedWrappers + = new ConcurrentDictionary>(); + + public static bool SupportsCSharp7 { get; } + = Enum.GetNames(typeof(SyntaxKind)).Contains(nameof(SyntaxKindEx.IsPatternExpression)); + + internal static bool CanWrapNode(SyntaxNode node, Type underlyingType) + { + if (node == null) + { + // The wrappers support a null instance + return true; + } + + if (underlyingType == null) + { + // The current runtime doesn't define the target type of the conversion, so no instance of it can exist + return false; + } + + ConcurrentDictionary wrappedSyntax = SupportedWrappers.GetOrAdd(underlyingType, _ => new ConcurrentDictionary()); + + // Avoid creating the delegate if the value already exists + bool canCast; + if (!wrappedSyntax.TryGetValue(node.Kind(), out canCast)) + { + canCast = wrappedSyntax.GetOrAdd( + node.Kind(), + kind => underlyingType.GetTypeInfo().IsAssignableFrom(node.GetType().GetTypeInfo())); + } + + return canCast; + } + + internal static Func CreateSyntaxPropertyAccessor(Type type, string propertyName) + { + Func fallbackAccessor = + syntax => + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return default(TProperty); + }; + + if (type == null) + { + return fallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return fallbackAccessor; + } + + if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + + Expression> expression = + Expression.Lambda>( + Expression.Call(instance, property.GetMethod), + syntaxParameter); + return expression.Compile(); + } + + internal static Func> CreateSeparatedSyntaxListPropertyAccessor(Type type, string propertyName) + { + Func> fallbackAccessor = + syntax => + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return SeparatedSyntaxListWrapper.UnsupportedEmpty; + }; + + if (type == null) + { + return fallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return fallbackAccessor; + } + + if (property.PropertyType.GetGenericTypeDefinition() != typeof(SeparatedSyntaxList<>)) + { + throw new InvalidOperationException(); + } + + var propertySyntaxType = property.PropertyType.GenericTypeArguments[0]; + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + Expression propertyAccess = Expression.Call(instance, property.GetMethod); + + var unboundWrapperType = typeof(SeparatedSyntaxListWrapper<>.AutoWrapSeparatedSyntaxList<>); + var boundWrapperType = unboundWrapperType.MakeGenericType(typeof(TProperty), propertySyntaxType); + var constructorInfo = boundWrapperType.GetTypeInfo().DeclaredConstructors.Single(); + + Expression>> expression = + Expression.Lambda>>( + Expression.New(constructorInfo, propertyAccess), + syntaxParameter); + return expression.Compile(); + } + + internal static Func CreateSyntaxWithPropertyAccessor(Type type, string propertyName) + { + Func fallbackAccessor = + (syntax, newValue) => + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + if (Equals(newValue, default(TProperty))) + { + return syntax; + } + + throw new NotSupportedException(); + }; + + if (type == null) + { + return fallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return fallbackAccessor; + } + + if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var methodInfo = type.GetTypeInfo().GetDeclaredMethods("With" + propertyName) + .Single(m => !m.IsStatic && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType.Equals(property.PropertyType)); + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + var valueParameter = Expression.Parameter(typeof(TProperty), methodInfo.GetParameters()[0].Name); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + Expression value = + property.PropertyType.GetTypeInfo().IsAssignableFrom(typeof(TProperty).GetTypeInfo()) + ? (Expression)valueParameter + : Expression.Convert(valueParameter, property.PropertyType); + + Expression> expression = + Expression.Lambda>( + Expression.Call(instance, methodInfo, value), + syntaxParameter, + valueParameter); + return expression.Compile(); + } + + internal static Func, TSyntax> CreateSeparatedSyntaxListWithPropertyAccessor(Type type, string propertyName) + { + Func, TSyntax> fallbackAccessor = + (syntax, newValue) => + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + if (ReferenceEquals(newValue, null)) + { + return syntax; + } + + throw new NotSupportedException(); + }; + + if (type == null) + { + return fallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return fallbackAccessor; + } + + if (property.PropertyType.GetGenericTypeDefinition() != typeof(SeparatedSyntaxList<>)) + { + throw new InvalidOperationException(); + } + + var propertySyntaxType = property.PropertyType.GenericTypeArguments[0]; + + var methodInfo = type.GetTypeInfo().GetDeclaredMethods("With" + propertyName) + .Single(m => !m.IsStatic && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType.Equals(property.PropertyType)); + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + var valueParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), methodInfo.GetParameters()[0].Name); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + Expression value = Expression.Convert( + Expression.Call(valueParameter, underlyingListProperty.GetMethod), + property.PropertyType); + + Expression, TSyntax>> expression = + Expression.Lambda, TSyntax>>( + Expression.Call(instance, methodInfo, value), + syntaxParameter, + valueParameter); + return expression.Compile(); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs new file mode 100644 index 000000000..7bd41c785 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs @@ -0,0 +1,237 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct LocalFunctionStatementSyntaxWrapper : ISyntaxWrapper + { + private const string LocalFunctionStatementSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax"; + private static readonly Type LocalFunctionStatementSyntaxType; + + private static readonly Func ModifiersAccessor; + private static readonly Func ReturnTypeAccessor; + private static readonly Func IdentifierAccessor; + private static readonly Func TypeParameterListAccessor; + private static readonly Func ParameterListAccessor; + private static readonly Func> ConstraintClausesAccessor; + private static readonly Func BodyAccessor; + private static readonly Func ExpressionBodyAccessor; + private static readonly Func SemicolonTokenAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithReturnTypeAccessor; + private static readonly Func WithIdentifierAccessor; + private static readonly Func WithTypeParameterListAccessor; + private static readonly Func WithParameterListAccessor; + private static readonly Func, StatementSyntax> WithConstraintClausesAccessor; + private static readonly Func WithBodyAccessor; + private static readonly Func WithExpressionBodyAccessor; + private static readonly Func WithSemicolonTokenAccessor; + + private readonly StatementSyntax node; + + static LocalFunctionStatementSyntaxWrapper() + { + LocalFunctionStatementSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(LocalFunctionStatementSyntaxTypeName); + ModifiersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Modifiers)); + ReturnTypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ReturnType)); + IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Identifier)); + TypeParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(TypeParameterList)); + ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ParameterList)); + ConstraintClausesAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(LocalFunctionStatementSyntaxType, nameof(ConstraintClauses)); + BodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Body)); + ExpressionBodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ExpressionBody)); + SemicolonTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(SemicolonToken)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Modifiers)); + WithReturnTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ReturnType)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Identifier)); + WithTypeParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(TypeParameterList)); + WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ParameterList)); + WithConstraintClausesAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(LocalFunctionStatementSyntaxType, nameof(ConstraintClauses)); + WithBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(Body)); + WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(ExpressionBody)); + WithSemicolonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(LocalFunctionStatementSyntaxType, nameof(SemicolonToken)); + } + + private LocalFunctionStatementSyntaxWrapper(StatementSyntax node) + { + this.node = node; + } + + public StatementSyntax SyntaxNode => this.node; + + public SyntaxTokenList Modifiers + { + get + { + return ModifiersAccessor(this.SyntaxNode); + } + } + + public TypeSyntax ReturnType + { + get + { + return ReturnTypeAccessor(this.SyntaxNode); + } + } + + public SyntaxToken Identifier + { + get + { + return IdentifierAccessor(this.SyntaxNode); + } + } + + public TypeParameterListSyntax TypeParameterList + { + get + { + return TypeParameterListAccessor(this.SyntaxNode); + } + } + + public ParameterListSyntax ParameterList + { + get + { + return ParameterListAccessor(this.SyntaxNode); + } + } + + public SyntaxList ConstraintClauses + { + get + { + return ConstraintClausesAccessor(this.SyntaxNode); + } + } + + public BlockSyntax Body + { + get + { + return BodyAccessor(this.SyntaxNode); + } + } + + public ArrowExpressionClauseSyntax ExpressionBody + { + get + { + return ExpressionBodyAccessor(this.SyntaxNode); + } + } + + public SyntaxToken SemicolonToken + { + get + { + return SemicolonTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator LocalFunctionStatementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(LocalFunctionStatementSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{LocalFunctionStatementSyntaxTypeName}'"); + } + + return new LocalFunctionStatementSyntaxWrapper((StatementSyntax)node); + } + + public static implicit operator StatementSyntax(LocalFunctionStatementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, LocalFunctionStatementSyntaxType); + } + + public LocalFunctionStatementSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new LocalFunctionStatementSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public LocalFunctionStatementSyntaxWrapper WithReturnType(TypeSyntax returnType) + { + return new LocalFunctionStatementSyntaxWrapper(WithReturnTypeAccessor(this.SyntaxNode, returnType)); + } + + public LocalFunctionStatementSyntaxWrapper WithIdentifier(SyntaxToken identifier) + { + return new LocalFunctionStatementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + } + + public LocalFunctionStatementSyntaxWrapper WithTypeParameterList(TypeParameterListSyntax typeParameterList) + { + return new LocalFunctionStatementSyntaxWrapper(WithTypeParameterListAccessor(this.SyntaxNode, typeParameterList)); + } + + public LocalFunctionStatementSyntaxWrapper WithParameterList(ParameterListSyntax parameterList) + { + return new LocalFunctionStatementSyntaxWrapper(WithParameterListAccessor(this.SyntaxNode, parameterList)); + } + + public LocalFunctionStatementSyntaxWrapper WithConstraintClauses(SyntaxList constraintClauses) + { + return new LocalFunctionStatementSyntaxWrapper(WithConstraintClausesAccessor(this.SyntaxNode, constraintClauses)); + } + + public LocalFunctionStatementSyntaxWrapper WithBody(BlockSyntax body) + { + return new LocalFunctionStatementSyntaxWrapper(WithBodyAccessor(this.SyntaxNode, body)); + } + + public LocalFunctionStatementSyntaxWrapper WithExpressionBody(ArrowExpressionClauseSyntax expressionBody) + { + return new LocalFunctionStatementSyntaxWrapper(WithExpressionBodyAccessor(this.SyntaxNode, expressionBody)); + } + + public LocalFunctionStatementSyntaxWrapper WithSemicolonToken(SyntaxToken semicolonToken) + { + return new LocalFunctionStatementSyntaxWrapper(WithSemicolonTokenAccessor(this.SyntaxNode, semicolonToken)); + } + + public LocalFunctionStatementSyntaxWrapper AddModifiers(params SyntaxToken[] items) + { + return this.WithModifiers(this.Modifiers.AddRange(items)); + } + + public LocalFunctionStatementSyntaxWrapper AddTypeParameterListParameters(params TypeParameterSyntax[] items) + { + var typeParameterList = this.TypeParameterList ?? SyntaxFactory.TypeParameterList(); + return this.WithTypeParameterList(typeParameterList.WithParameters(typeParameterList.Parameters.AddRange(items))); + } + + public LocalFunctionStatementSyntaxWrapper AddParameterListParameters(params ParameterSyntax[] items) + { + return this.WithParameterList(this.ParameterList.WithParameters(this.ParameterList.Parameters.AddRange(items))); + } + + public LocalFunctionStatementSyntaxWrapper AddConstraintClauses(params TypeParameterConstraintClauseSyntax[] items) + { + return this.WithConstraintClauses(this.ConstraintClauses.AddRange(items)); + } + + public LocalFunctionStatementSyntaxWrapper AddBodyStatements(params StatementSyntax[] items) + { + var body = this.Body ?? SyntaxFactory.Block(); + return this.WithBody(body.WithStatements(body.Statements.AddRange(items))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs new file mode 100644 index 000000000..4449b3531 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs @@ -0,0 +1,12 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + internal static class MethodKindEx + { + public const MethodKind LocalFunction = (MethodKind)17; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs new file mode 100644 index 000000000..48d14e66d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs @@ -0,0 +1,122 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal struct ParenthesizedVariableDesignationSyntaxWrapper : ISyntaxWrapper + { + private const string ParenthesizedVariableDesignationSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax"; + private static readonly Type ParenthesizedVariableDesignationSyntaxType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> VariablesAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithVariablesAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static ParenthesizedVariableDesignationSyntaxWrapper() + { + ParenthesizedVariableDesignationSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(ParenthesizedVariableDesignationSyntaxTypeName); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(OpenParenToken)); + VariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(Variables)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(OpenParenToken)); + WithVariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(Variables)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ParenthesizedVariableDesignationSyntaxType, nameof(CloseParenToken)); + } + + private ParenthesizedVariableDesignationSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Variables + { + get + { + return VariablesAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(VariableDesignationSyntaxWrapper node) + { + return (ParenthesizedVariableDesignationSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(ParenthesizedVariableDesignationSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{ParenthesizedVariableDesignationSyntaxTypeName}'"); + } + + return new ParenthesizedVariableDesignationSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator VariableDesignationSyntaxWrapper(ParenthesizedVariableDesignationSyntaxWrapper wrapper) + { + return VariableDesignationSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(ParenthesizedVariableDesignationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, ParenthesizedVariableDesignationSyntaxType); + } + + public ParenthesizedVariableDesignationSyntaxWrapper AddVariables(params VariableDesignationSyntaxWrapper[] items) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(this.WithVariables(this.Variables.AddRange(items))); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithOpenParenToken(SyntaxToken identifier) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, identifier)); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithVariables(SeparatedSyntaxListWrapper variables) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithVariablesAccessor(this.SyntaxNode, variables)); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithCloseParenToken(SyntaxToken identifier) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, identifier)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs new file mode 100644 index 000000000..631855493 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal struct PatternSyntaxWrapper : ISyntaxWrapper + { + private const string PatternSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax"; + private static readonly Type PatternSyntaxType; + + private readonly CSharpSyntaxNode node; + + static PatternSyntaxWrapper() + { + PatternSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(PatternSyntaxTypeName); + } + + private PatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public static explicit operator PatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(PatternSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{PatternSyntaxTypeName}'"); + } + + return new PatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(PatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, PatternSyntaxType); + } + + internal static PatternSyntaxWrapper FromUpcast(CSharpSyntaxNode node) + { + return new PatternSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..6d1e9d985 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct RefExpressionSyntaxWrapper : ISyntaxWrapper + { + private const string RefExpressionSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax"; + private static readonly Type RefExpressionSyntaxType; + + private static readonly Func RefKeywordAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func WithRefKeywordAccessor; + private static readonly Func WithExpressionAccessor; + + private readonly ExpressionSyntax node; + + static RefExpressionSyntaxWrapper() + { + RefExpressionSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(RefExpressionSyntaxTypeName); + RefKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(RefExpressionSyntaxType, nameof(RefKeyword)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(RefExpressionSyntaxType, nameof(Expression)); + WithRefKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(RefExpressionSyntaxType, nameof(RefKeyword)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(RefExpressionSyntaxType, nameof(Expression)); + } + + private RefExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken RefKeyword + { + get + { + return RefKeywordAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public static explicit operator RefExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(RefExpressionSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{RefExpressionSyntaxTypeName}'"); + } + + return new RefExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(RefExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, RefExpressionSyntaxType); + } + + public RefExpressionSyntaxWrapper WithRefKeyword(SyntaxToken refKeyword) + { + return new RefExpressionSyntaxWrapper(WithRefKeywordAccessor(this.SyntaxNode, refKeyword)); + } + + public RefExpressionSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new RefExpressionSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs new file mode 100644 index 000000000..ac5c50863 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct RefTypeSyntaxWrapper : ISyntaxWrapper + { + private const string RefTypeSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax"; + private static readonly Type RefTypeSyntaxType; + + private static readonly Func RefKeywordAccessor; + private static readonly Func TypeAccessor; + private static readonly Func WithRefKeywordAccessor; + private static readonly Func WithTypeAccessor; + + private readonly TypeSyntax node; + + static RefTypeSyntaxWrapper() + { + RefTypeSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(RefTypeSyntaxTypeName); + RefKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(RefTypeSyntaxType, nameof(RefKeyword)); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(RefTypeSyntaxType, nameof(Type)); + WithRefKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(RefTypeSyntaxType, nameof(RefKeyword)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(RefTypeSyntaxType, nameof(Type)); + } + + private RefTypeSyntaxWrapper(TypeSyntax node) + { + this.node = node; + } + + public TypeSyntax SyntaxNode => this.node; + + public SyntaxToken RefKeyword + { + get + { + return RefKeywordAccessor(this.SyntaxNode); + } + } + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public static explicit operator RefTypeSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(RefTypeSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{RefTypeSyntaxTypeName}'"); + } + + return new RefTypeSyntaxWrapper((TypeSyntax)node); + } + + public static implicit operator TypeSyntax(RefTypeSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, RefTypeSyntaxType); + } + + public RefTypeSyntaxWrapper WithRefKeyword(SyntaxToken refKeyword) + { + return new RefTypeSyntaxWrapper(WithRefKeywordAccessor(this.SyntaxNode, refKeyword)); + } + + public RefTypeSyntaxWrapper WithType(TypeSyntax type) + { + return new RefTypeSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs new file mode 100644 index 000000000..9641e6881 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs @@ -0,0 +1,394 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.ComponentModel; + using System.Linq; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Text; + + internal abstract class SeparatedSyntaxListWrapper : IEquatable>, IReadOnlyList + { + private static readonly SyntaxWrapper SyntaxWrapper = SyntaxWrapper.Default; + + public static SeparatedSyntaxListWrapper UnsupportedEmpty { get; } = + new UnsupportedSyntaxList(); + + public abstract int Count + { + get; + } + + public abstract TextSpan FullSpan + { + get; + } + + public abstract int SeparatorCount + { + get; + } + + public abstract TextSpan Span + { + get; + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract object UnderlyingList + { + get; + } + + public abstract TNode this[int index] + { + get; + } + + public static bool operator ==(SeparatedSyntaxListWrapper left, SeparatedSyntaxListWrapper right) + { + throw new NotImplementedException(); + } + + public static bool operator !=(SeparatedSyntaxListWrapper left, SeparatedSyntaxListWrapper right) + { + throw new NotImplementedException(); + } + + // Summary: + // Creates a new list with the specified node added to the end. + // + // Parameters: + // node: + // The node to add. + public SeparatedSyntaxListWrapper Add(TNode node) + { + throw new NotImplementedException(); + } + + // Summary: + // Creates a new list with the specified nodes added to the end. + // + // Parameters: + // nodes: + // The nodes to add. + public SeparatedSyntaxListWrapper AddRange(IEnumerable nodes) + { + throw new NotImplementedException(); + } + + public abstract bool Any(); + + public abstract bool Contains(TNode node); + + public bool Equals(SeparatedSyntaxListWrapper other) + { + throw new NotImplementedException(); + } + + public override bool Equals(object obj) + { + throw new NotImplementedException(); + } + + public abstract TNode First(); + + public abstract TNode FirstOrDefault(); + + public Enumerator GetEnumerator() + { + throw new NotImplementedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)this).GetEnumerator(); + } + + public override abstract int GetHashCode(); + + public abstract SyntaxToken GetSeparator(int index); + + public abstract IEnumerable GetSeparators(); + + public abstract SyntaxNodeOrTokenList GetWithSeparators(); + + public abstract int IndexOf(Func predicate); + + public abstract int IndexOf(TNode node); + + public abstract SeparatedSyntaxListWrapper Insert(int index, TNode node); + + public abstract SeparatedSyntaxListWrapper InsertRange(int index, IEnumerable nodes); + + public abstract TNode Last(); + + public abstract int LastIndexOf(Func predicate); + + public abstract int LastIndexOf(TNode node); + + public abstract TNode LastOrDefault(); + + public abstract SeparatedSyntaxListWrapper Remove(TNode node); + + public abstract SeparatedSyntaxListWrapper RemoveAt(int index); + + public abstract SeparatedSyntaxListWrapper Replace(TNode nodeInList, TNode newNode); + + public abstract SeparatedSyntaxListWrapper ReplaceRange(TNode nodeInList, IEnumerable newNodes); + + public abstract SeparatedSyntaxListWrapper ReplaceSeparator(SyntaxToken separatorToken, SyntaxToken newSeparator); + + public abstract string ToFullString(); + + public override abstract string ToString(); + + public struct Enumerator + { + public TNode Current + { + get + { + throw new NotImplementedException(); + } + } + + public override bool Equals(object obj) + { + throw new NotImplementedException(); + } + + public override int GetHashCode() + { + throw new NotImplementedException(); + } + + public bool MoveNext() + { + throw new NotImplementedException(); + } + + public void Reset() + { + throw new NotImplementedException(); + } + } + + internal sealed class AutoWrapSeparatedSyntaxList : SeparatedSyntaxListWrapper + where TSyntax : SyntaxNode + { + private readonly SeparatedSyntaxList syntaxList; + + public AutoWrapSeparatedSyntaxList(SeparatedSyntaxList syntaxList) + { + this.syntaxList = syntaxList; + } + + public override int Count + => this.syntaxList.Count; + + public override TextSpan FullSpan + => this.syntaxList.FullSpan; + + public override int SeparatorCount + => this.syntaxList.SeparatorCount; + + public override TextSpan Span + => this.syntaxList.Span; + + public override object UnderlyingList + => this.syntaxList; + + public override TNode this[int index] + => SyntaxWrapper.Wrap(this.syntaxList[index]); + + public override bool Any() + => this.syntaxList.Any(); + + public override bool Contains(TNode node) + => this.syntaxList.Contains(SyntaxWrapper.Unwrap(node)); + + public override TNode First() + => SyntaxWrapper.Wrap(this.syntaxList.First()); + + public override TNode FirstOrDefault() + => SyntaxWrapper.Wrap(this.syntaxList.FirstOrDefault()); + + public override int GetHashCode() + => this.syntaxList.GetHashCode(); + + public override SyntaxToken GetSeparator(int index) + => this.syntaxList.GetSeparator(index); + + public override IEnumerable GetSeparators() + => this.syntaxList.GetSeparators(); + + public override SyntaxNodeOrTokenList GetWithSeparators() + => this.syntaxList.GetWithSeparators(); + + public override int IndexOf(TNode node) + => this.syntaxList.IndexOf((TSyntax)SyntaxWrapper.Unwrap(node)); + + public override int IndexOf(Func predicate) + => this.syntaxList.IndexOf(node => predicate(SyntaxWrapper.Wrap(node))); + + public override SeparatedSyntaxListWrapper Insert(int index, TNode node) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.Insert(index, (TSyntax)SyntaxWrapper.Unwrap(node))); + + public override SeparatedSyntaxListWrapper InsertRange(int index, IEnumerable nodes) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.InsertRange(index, nodes.Select(node => (TSyntax)SyntaxWrapper.Unwrap(node)))); + + public override TNode Last() + => SyntaxWrapper.Wrap(this.syntaxList.Last()); + + public override int LastIndexOf(TNode node) + => this.syntaxList.LastIndexOf((TSyntax)SyntaxWrapper.Unwrap(node)); + + public override int LastIndexOf(Func predicate) + => this.syntaxList.LastIndexOf(node => predicate(SyntaxWrapper.Wrap(node))); + + public override TNode LastOrDefault() + => SyntaxWrapper.Wrap(this.syntaxList.LastOrDefault()); + + public override SeparatedSyntaxListWrapper Remove(TNode node) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.Remove((TSyntax)SyntaxWrapper.Unwrap(node))); + + public override SeparatedSyntaxListWrapper RemoveAt(int index) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.RemoveAt(index)); + + public override SeparatedSyntaxListWrapper Replace(TNode nodeInList, TNode newNode) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.Replace((TSyntax)SyntaxWrapper.Unwrap(nodeInList), (TSyntax)SyntaxWrapper.Unwrap(newNode))); + + public override SeparatedSyntaxListWrapper ReplaceRange(TNode nodeInList, IEnumerable newNodes) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.ReplaceRange((TSyntax)SyntaxWrapper.Unwrap(nodeInList), newNodes.Select(node => (TSyntax)SyntaxWrapper.Unwrap(node)))); + + public override SeparatedSyntaxListWrapper ReplaceSeparator(SyntaxToken separatorToken, SyntaxToken newSeparator) + => new AutoWrapSeparatedSyntaxList(this.syntaxList.ReplaceSeparator(separatorToken, newSeparator)); + + public override string ToFullString() + => this.syntaxList.ToFullString(); + + public override string ToString() + => this.syntaxList.ToString(); + } + + private sealed class UnsupportedSyntaxList : SeparatedSyntaxListWrapper + { + private static readonly SeparatedSyntaxList SyntaxList = default(SeparatedSyntaxList); + + public UnsupportedSyntaxList() + { + } + + public override int Count + => 0; + + public override TextSpan FullSpan + => SyntaxList.FullSpan; + + public override int SeparatorCount + => 0; + + public override TextSpan Span + => SyntaxList.Span; + + public override object UnderlyingList + => null; + + public override TNode this[int index] + => SyntaxWrapper.Wrap(SyntaxList[index]); + + public override bool Any() + => false; + + public override bool Contains(TNode node) + => false; + + public override TNode First() + => SyntaxWrapper.Wrap(SyntaxList.First()); + + public override TNode FirstOrDefault() + => SyntaxWrapper.Wrap(default(SyntaxNode)); + + public override int GetHashCode() + => SyntaxList.GetHashCode(); + + public override SyntaxToken GetSeparator(int index) + => SyntaxList.GetSeparator(index); + + public override IEnumerable GetSeparators() + => SyntaxList.GetSeparators(); + + public override SyntaxNodeOrTokenList GetWithSeparators() + => SyntaxList.GetWithSeparators(); + + public override int IndexOf(TNode node) + => SyntaxList.IndexOf(SyntaxWrapper.Unwrap(node)); + + public override int IndexOf(Func predicate) + => SyntaxList.IndexOf(node => predicate(SyntaxWrapper.Wrap(node))); + + public override SeparatedSyntaxListWrapper Insert(int index, TNode node) + { + throw new NotSupportedException(); + } + + public override SeparatedSyntaxListWrapper InsertRange(int index, IEnumerable nodes) + { + throw new NotSupportedException(); + } + + public override TNode Last() + => SyntaxWrapper.Wrap(SyntaxList.Last()); + + public override int LastIndexOf(TNode node) + => SyntaxList.LastIndexOf(SyntaxWrapper.Unwrap(node)); + + public override int LastIndexOf(Func predicate) + => SyntaxList.LastIndexOf(node => predicate(SyntaxWrapper.Wrap(node))); + + public override TNode LastOrDefault() + => SyntaxWrapper.Wrap(default(SyntaxNode)); + + public override SeparatedSyntaxListWrapper Remove(TNode node) + { + throw new NotSupportedException(); + } + + public override SeparatedSyntaxListWrapper RemoveAt(int index) + { + throw new NotSupportedException(); + } + + public override SeparatedSyntaxListWrapper Replace(TNode nodeInList, TNode newNode) + { + throw new NotSupportedException(); + } + + public override SeparatedSyntaxListWrapper ReplaceRange(TNode nodeInList, IEnumerable newNodes) + { + throw new NotSupportedException(); + } + + public override SeparatedSyntaxListWrapper ReplaceSeparator(SyntaxToken separatorToken, SyntaxToken newSeparator) + { + throw new NotSupportedException(); + } + + public override string ToFullString() + => SyntaxList.ToFullString(); + + public override string ToString() + => SyntaxList.ToString(); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs new file mode 100644 index 000000000..86a836c80 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs @@ -0,0 +1,83 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal struct SingleVariableDesignationSyntaxWrapper : ISyntaxWrapper + { + private const string SingleVariableDesignationSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax"; + private static readonly Type SingleVariableDesignationSyntaxType; + + private static readonly Func IdentifierAccessor; + private static readonly Func WithIdentifierAccessor; + + private readonly CSharpSyntaxNode node; + + static SingleVariableDesignationSyntaxWrapper() + { + SingleVariableDesignationSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(SingleVariableDesignationSyntaxTypeName); + IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(SingleVariableDesignationSyntaxType, nameof(Identifier)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(SingleVariableDesignationSyntaxType, nameof(Identifier)); + } + + private SingleVariableDesignationSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken Identifier + { + get + { + return IdentifierAccessor(this.SyntaxNode); + } + } + + public static explicit operator SingleVariableDesignationSyntaxWrapper(VariableDesignationSyntaxWrapper node) + { + return (SingleVariableDesignationSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator SingleVariableDesignationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(SingleVariableDesignationSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{SingleVariableDesignationSyntaxTypeName}'"); + } + + return new SingleVariableDesignationSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator VariableDesignationSyntaxWrapper(SingleVariableDesignationSyntaxWrapper wrapper) + { + return VariableDesignationSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(SingleVariableDesignationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, SingleVariableDesignationSyntaxType); + } + + public SingleVariableDesignationSyntaxWrapper WithIdentifier(SyntaxToken identifier) + { + return new SingleVariableDesignationSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs new file mode 100644 index 000000000..010008d05 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs @@ -0,0 +1,12 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + internal static class SymbolDisplayLocalOptionsEx + { + public const SymbolDisplayLocalOptions IncludeRef = (SymbolDisplayLocalOptions)4; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs new file mode 100644 index 000000000..bf111a3f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs @@ -0,0 +1,12 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + internal static class SymbolDisplayMemberOptionsEx + { + public const SymbolDisplayMemberOptions IncludeRef = (SymbolDisplayMemberOptions)128; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs new file mode 100644 index 000000000..defc2a50f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs @@ -0,0 +1,12 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + internal static class SymbolKindEx + { + public const SymbolKind Discard = (SymbolKind)19; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs new file mode 100644 index 000000000..1c06a4699 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs @@ -0,0 +1,29 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + + internal static class SyntaxKindEx + { + public const SyntaxKind UnderscoreToken = (SyntaxKind)8491; + public const SyntaxKind IsPatternExpression = (SyntaxKind)8657; + public const SyntaxKind LocalFunctionStatement = (SyntaxKind)8830; + public const SyntaxKind TupleType = (SyntaxKind)8924; + public const SyntaxKind TupleElement = (SyntaxKind)8925; + public const SyntaxKind TupleExpression = (SyntaxKind)8926; + public const SyntaxKind SingleVariableDesignation = (SyntaxKind)8927; + public const SyntaxKind ParenthesizedVariableDesignation = (SyntaxKind)8928; + public const SyntaxKind ForEachVariableStatement = (SyntaxKind)8929; + public const SyntaxKind DeclarationPattern = (SyntaxKind)9000; + public const SyntaxKind ConstantPattern = (SyntaxKind)9002; + public const SyntaxKind CasePatternSwitchLabel = (SyntaxKind)9009; + public const SyntaxKind WhenClause = (SyntaxKind)9013; + public const SyntaxKind DiscardDesignation = (SyntaxKind)9014; + public const SyntaxKind DeclarationExpression = (SyntaxKind)9040; + public const SyntaxKind RefExpression = (SyntaxKind)9050; + public const SyntaxKind RefType = (SyntaxKind)9051; + public const SyntaxKind ThrowExpression = (SyntaxKind)9052; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs new file mode 100644 index 000000000..29a001a27 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs @@ -0,0 +1,74 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Linq; + using System.Linq.Expressions; + using System.Reflection; + using Microsoft.CodeAnalysis; + + internal abstract class SyntaxWrapper + { + public static SyntaxWrapper Default { get; } = FindDefaultSyntaxWrapper(); + + public abstract TNode Wrap(SyntaxNode node); + + public abstract SyntaxNode Unwrap(TNode node); + + private static SyntaxWrapper FindDefaultSyntaxWrapper() + { + if (typeof(SyntaxNode).GetTypeInfo().IsAssignableFrom(typeof(TNode).GetTypeInfo())) + { + return new DirectCastSyntaxWrapper(); + } + + return new ConversionSyntaxWrapper(); + } + + private sealed class DirectCastSyntaxWrapper : SyntaxWrapper + { + public override SyntaxNode Unwrap(TNode node) + { + return (SyntaxNode)(object)node; + } + + public override TNode Wrap(SyntaxNode node) + { + return (TNode)(object)node; + } + } + + private sealed class ConversionSyntaxWrapper : SyntaxWrapper + { + private readonly Func unwrapAccessor; + private readonly Func wrapAccessor; + + public ConversionSyntaxWrapper() + { + this.unwrapAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(TNode), nameof(ISyntaxWrapper.SyntaxNode)); + + var explicitOperator = typeof(TNode).GetTypeInfo().GetDeclaredMethods("op_Explicit") + .Single(m => m.ReturnType == typeof(TNode) && m.GetParameters()[0].ParameterType == typeof(SyntaxNode)); + var syntaxParameter = Expression.Parameter(typeof(SyntaxNode), "syntax"); + Expression> wrapAccessorExpression = + Expression.Lambda>( + Expression.Call(explicitOperator, syntaxParameter), + syntaxParameter); + + this.wrapAccessor = wrapAccessorExpression.Compile(); + } + + public override SyntaxNode Unwrap(TNode node) + { + return this.unwrapAccessor(node); + } + + public override TNode Wrap(SyntaxNode node) + { + return this.wrapAccessor(node); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..5a93dae2b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct ThrowExpressionSyntaxWrapper : ISyntaxWrapper + { + private const string ThrowExpressionSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax"; + private static readonly Type ThrowExpressionSyntaxType; + + private static readonly Func ThrowKeywordAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func WithThrowKeywordAccessor; + private static readonly Func WithExpressionAccessor; + + private readonly ExpressionSyntax node; + + static ThrowExpressionSyntaxWrapper() + { + ThrowExpressionSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(ThrowExpressionSyntaxTypeName); + ThrowKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ThrowExpressionSyntaxType, nameof(ThrowKeyword)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(ThrowExpressionSyntaxType, nameof(Expression)); + WithThrowKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ThrowExpressionSyntaxType, nameof(ThrowKeyword)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(ThrowExpressionSyntaxType, nameof(Expression)); + } + + private ThrowExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken ThrowKeyword + { + get + { + return ThrowKeywordAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public static explicit operator ThrowExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(ThrowExpressionSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{ThrowExpressionSyntaxTypeName}'"); + } + + return new ThrowExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(ThrowExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, ThrowExpressionSyntaxType); + } + + public ThrowExpressionSyntaxWrapper WithThrowKeyword(SyntaxToken throwKeyword) + { + return new ThrowExpressionSyntaxWrapper(WithThrowKeywordAccessor(this.SyntaxNode, throwKeyword)); + } + + public ThrowExpressionSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new ThrowExpressionSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs new file mode 100644 index 000000000..d8ed13bf0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct TupleElementSyntaxWrapper : ISyntaxWrapper + { + private const string TupleElementSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax"; + private static readonly Type TupleElementSyntaxType; + + private static readonly Func IdentifierAccessor; + private static readonly Func TypeAccessor; + private static readonly Func WithIdentifierAccessor; + private static readonly Func WithTypeAccessor; + + private readonly CSharpSyntaxNode node; + + static TupleElementSyntaxWrapper() + { + TupleElementSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(TupleElementSyntaxTypeName); + IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleElementSyntaxType, nameof(Identifier)); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleElementSyntaxType, nameof(Type)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleElementSyntaxType, nameof(Identifier)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleElementSyntaxType, nameof(Type)); + } + + private TupleElementSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken Identifier + { + get + { + return IdentifierAccessor(this.SyntaxNode); + } + } + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public static explicit operator TupleElementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(TupleElementSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{TupleElementSyntaxTypeName}'"); + } + + return new TupleElementSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(TupleElementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, TupleElementSyntaxType); + } + + public TupleElementSyntaxWrapper WithIdentifier(SyntaxToken identifier) + { + return new TupleElementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + } + + public TupleElementSyntaxWrapper WithType(TypeSyntax type) + { + return new TupleElementSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..b199cacb0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs @@ -0,0 +1,113 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct TupleExpressionSyntaxWrapper : ISyntaxWrapper + { + private const string TupleExpressionSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax"; + private static readonly Type TupleExpressionSyntaxType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> ArgumentsAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, ExpressionSyntax> WithArgumentsAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly ExpressionSyntax node; + + static TupleExpressionSyntaxWrapper() + { + TupleExpressionSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(TupleExpressionSyntaxTypeName); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleExpressionSyntaxType, nameof(OpenParenToken)); + ArgumentsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(TupleExpressionSyntaxType, nameof(Arguments)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleExpressionSyntaxType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleExpressionSyntaxType, nameof(OpenParenToken)); + WithArgumentsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(TupleExpressionSyntaxType, nameof(Arguments)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleExpressionSyntaxType, nameof(CloseParenToken)); + } + + private TupleExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxList Arguments + { + get + { + return ArgumentsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator TupleExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(TupleExpressionSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{TupleExpressionSyntaxTypeName}'"); + } + + return new TupleExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(TupleExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, TupleExpressionSyntaxType); + } + + public TupleExpressionSyntaxWrapper AddArguments(params ArgumentSyntax[] items) + { + return new TupleExpressionSyntaxWrapper(this.WithArguments(this.Arguments.AddRange(items))); + } + + public TupleExpressionSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new TupleExpressionSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public TupleExpressionSyntaxWrapper WithArguments(SeparatedSyntaxList arguments) + { + return new TupleExpressionSyntaxWrapper(WithArgumentsAccessor(this.SyntaxNode, arguments)); + } + + public TupleExpressionSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new TupleExpressionSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs new file mode 100644 index 000000000..a165c8df8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs @@ -0,0 +1,113 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct TupleTypeSyntaxWrapper : ISyntaxWrapper + { + private const string TupleTypeSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax"; + private static readonly Type TupleTypeSyntaxType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> ElementsAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, TypeSyntax> WithElementsAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly TypeSyntax node; + + static TupleTypeSyntaxWrapper() + { + TupleTypeSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(TupleTypeSyntaxTypeName); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleTypeSyntaxType, nameof(OpenParenToken)); + ElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(TupleTypeSyntaxType, nameof(Elements)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(TupleTypeSyntaxType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleTypeSyntaxType, nameof(OpenParenToken)); + WithElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(TupleTypeSyntaxType, nameof(Elements)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(TupleTypeSyntaxType, nameof(CloseParenToken)); + } + + private TupleTypeSyntaxWrapper(TypeSyntax node) + { + this.node = node; + } + + public TypeSyntax SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Elements + { + get + { + return ElementsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator TupleTypeSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(TupleTypeSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{TupleTypeSyntaxTypeName}'"); + } + + return new TupleTypeSyntaxWrapper((TypeSyntax)node); + } + + public static implicit operator TypeSyntax(TupleTypeSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, TupleTypeSyntaxType); + } + + public TupleTypeSyntaxWrapper AddElements(params TupleElementSyntaxWrapper[] items) + { + return new TupleTypeSyntaxWrapper(this.WithElements(this.Elements.AddRange(items))); + } + + public TupleTypeSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new TupleTypeSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public TupleTypeSyntaxWrapper WithElements(SeparatedSyntaxListWrapper elements) + { + return new TupleTypeSyntaxWrapper(WithElementsAccessor(this.SyntaxNode, elements)); + } + + public TupleTypeSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new TupleTypeSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs new file mode 100644 index 000000000..9b1368dc7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal struct VariableDesignationSyntaxWrapper : ISyntaxWrapper + { + private const string VariableDesignationSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax"; + private static readonly Type VariableDesignationSyntaxType; + + private readonly CSharpSyntaxNode node; + + static VariableDesignationSyntaxWrapper() + { + VariableDesignationSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(VariableDesignationSyntaxTypeName); + } + + private VariableDesignationSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public static explicit operator VariableDesignationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(VariableDesignationSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{VariableDesignationSyntaxTypeName}'"); + } + + return new VariableDesignationSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(VariableDesignationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, VariableDesignationSyntaxType); + } + + internal static VariableDesignationSyntaxWrapper FromUpcast(CSharpSyntaxNode node) + { + return new VariableDesignationSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WhenClauseSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WhenClauseSyntaxWrapper.cs new file mode 100644 index 000000000..a08e5519b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WhenClauseSyntaxWrapper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal struct WhenClauseSyntaxWrapper : ISyntaxWrapper + { + private const string WhenClauseSyntaxTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax"; + private static readonly Type WhenClauseSyntaxType; + + private static readonly Func WhenKeywordAccessor; + private static readonly Func ConditionAccessor; + private static readonly Func WithWhenKeywordAccessor; + private static readonly Func WithConditionAccessor; + + private readonly CSharpSyntaxNode node; + + static WhenClauseSyntaxWrapper() + { + WhenClauseSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(WhenClauseSyntaxTypeName); + WhenKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WhenClauseSyntaxType, nameof(WhenKeyword)); + ConditionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WhenClauseSyntaxType, nameof(Condition)); + WithWhenKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WhenClauseSyntaxType, nameof(WhenKeyword)); + WithConditionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WhenClauseSyntaxType, nameof(Condition)); + } + + private WhenClauseSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken WhenKeyword + { + get + { + return WhenKeywordAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Condition + { + get + { + return ConditionAccessor(this.SyntaxNode); + } + } + + public static explicit operator WhenClauseSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default(WhenClauseSyntaxWrapper); + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WhenClauseSyntaxTypeName}'"); + } + + return new WhenClauseSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(WhenClauseSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WhenClauseSyntaxType); + } + + public WhenClauseSyntaxWrapper WithWhenKeyword(SyntaxToken whenKeyword) + { + return new WhenClauseSyntaxWrapper(WithWhenKeywordAccessor(this.SyntaxNode, whenKeyword)); + } + + public WhenClauseSyntaxWrapper WithCondition(ExpressionSyntax condition) + { + return new WhenClauseSyntaxWrapper(WithConditionAccessor(this.SyntaxNode, condition)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs index 362100349..abdb12d85 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs @@ -45,4 +45,5 @@ [assembly: InternalsVisibleTo("StyleCop.Analyzers.CodeFixes, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ad62a4e5529344c07fe1455f270d61b205bdc8b0a94bcbe80b8506f28061073e4ed750b7e3d344f23213f671397a05e8c59b1434555f78edc091c0cf7b603011cf126aaa10116d890354f97f369ff56e24df17ee7f22cc3dd4d4b841d027d6d3d3b52a9a4462b8acf0f4bb9f400256ae18eed71070692e4cdd051498d04a66ed")] #endif [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCopTester, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj b/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj index ea4580193..625f62d6a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj @@ -176,6 +176,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True @@ -361,6 +395,7 @@ StyleCop.Analyzers.ruleset + diff --git a/StyleCopAnalyzers.sln b/StyleCopAnalyzers.sln index c2c863326..da23a9d14 100644 --- a/StyleCopAnalyzers.sln +++ b/StyleCopAnalyzers.sln @@ -247,6 +247,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCopTester", "StyleCop. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCop.Analyzers.CodeFixes", "StyleCop.Analyzers\StyleCop.Analyzers.CodeFixes\StyleCop.Analyzers.CodeFixes.csproj", "{F91F7815-4E63-4698-B053-E57B2D707194}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCop.Analyzers.Test.CSharp7", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\StyleCop.Analyzers.Test.CSharp7.csproj", "{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -273,6 +275,10 @@ Global {F91F7815-4E63-4698-B053-E57B2D707194}.Debug|Any CPU.Build.0 = Debug|Any CPU {F91F7815-4E63-4698-B053-E57B2D707194}.Release|Any CPU.ActiveCfg = Release|Any CPU {F91F7815-4E63-4698-B053-E57B2D707194}.Release|Any CPU.Build.0 = Release|Any CPU + {F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/appveyor.yml b/appveyor.yml index 2f2e848d2..3ab91a51d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,6 +11,7 @@ build: verbosity: minimal test_script: - .\packages\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"C:\projects\stylecopanalyzers\StyleCop.Analyzers\StyleCop.Analyzers.Test\bin\Debug\StyleCop.Analyzers.Test.dll -noshadow -appveyor" -returntargetcode -filter:"+[StyleCop*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -excludebyfile:*\*Designer.cs -hideskipped:All -output:.\StyleCopAnalyzers_coverage.xml +- .\packages\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"C:\projects\stylecopanalyzers\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\bin\Debug\StyleCop.Analyzers.Test.CSharp7.dll -noshadow -appveyor" -returntargetcode -filter:"+[StyleCop*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -excludebyfile:*\*Designer.cs -hideskipped:All -mergebyhash -mergeoutput -output:.\StyleCopAnalyzers_coverage.xml - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%" - pip install codecov - codecov -f "StyleCopAnalyzers_coverage.xml"