Skip to content

Commit efeef8d

Browse files
committed
Generate static fields before instance fields
1 parent 1ebaed9 commit efeef8d

48 files changed

Lines changed: 55 additions & 55 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ private void GenerateSyntaxWrapper(in GeneratorExecutionContext context, SyntaxD
8585
type: SyntaxFactory.IdentifierName("Type"),
8686
variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("WrappedType")))));
8787

88-
// private readonly SyntaxNode node;
89-
members = members.Add(SyntaxFactory.FieldDeclaration(
90-
attributeLists: default,
91-
modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)),
92-
declaration: SyntaxFactory.VariableDeclaration(
93-
type: SyntaxFactory.IdentifierName(concreteBase),
94-
variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("node")))));
95-
9688
foreach (var field in nodeData.Fields)
9789
{
9890
if (field.IsSkipped)
@@ -146,6 +138,14 @@ private void GenerateSyntaxWrapper(in GeneratorExecutionContext context, SyntaxD
146138
variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(field.WithAccessorName)))));
147139
}
148140

141+
// private readonly SyntaxNode node;
142+
members = members.Add(SyntaxFactory.FieldDeclaration(
143+
attributeLists: default,
144+
modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)),
145+
declaration: SyntaxFactory.VariableDeclaration(
146+
type: SyntaxFactory.IdentifierName(concreteBase),
147+
variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("node")))));
148+
149149
// WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SyntaxWrapper));
150150
var staticCtorStatements = SyntaxFactory.SingletonList<StatementSyntax>(
151151
SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression(

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseObjectCreationExpressionSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseObjectCreationExpressionSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly ExpressionSyntax node;
1716
private static readonly Func<ExpressionSyntax, SyntaxToken> NewKeywordAccessor;
1817
private static readonly Func<ExpressionSyntax, ArgumentListSyntax> ArgumentListAccessor;
1918
private static readonly Func<ExpressionSyntax, InitializerExpressionSyntax> InitializerAccessor;
2019
private static readonly Func<ExpressionSyntax, SyntaxToken, ExpressionSyntax> WithNewKeywordAccessor;
2120
private static readonly Func<ExpressionSyntax, ArgumentListSyntax, ExpressionSyntax> WithArgumentListAccessor;
2221
private static readonly Func<ExpressionSyntax, InitializerExpressionSyntax, ExpressionSyntax> WithInitializerAccessor;
22+
private readonly ExpressionSyntax node;
2323
static BaseObjectCreationExpressionSyntaxWrapper()
2424
{
2525
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseObjectCreationExpressionSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseParameterSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly CSharpSyntaxNode node;
1716
private static readonly Func<CSharpSyntaxNode, SyntaxList<AttributeListSyntax>> AttributeListsAccessor;
1817
private static readonly Func<CSharpSyntaxNode, SyntaxTokenList> ModifiersAccessor;
1918
private static readonly Func<CSharpSyntaxNode, TypeSyntax> TypeAccessor;
2019
private static readonly Func<CSharpSyntaxNode, SyntaxList<AttributeListSyntax>, CSharpSyntaxNode> WithAttributeListsAccessor;
2120
private static readonly Func<CSharpSyntaxNode, SyntaxTokenList, CSharpSyntaxNode> WithModifiersAccessor;
2221
private static readonly Func<CSharpSyntaxNode, TypeSyntax, CSharpSyntaxNode> WithTypeAccessor;
22+
private readonly CSharpSyntaxNode node;
2323
static BaseParameterSyntaxWrapper()
2424
{
2525
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseParameterSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BinaryPatternSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BinaryPatternSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly CSharpSyntaxNode node;
1716
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode> LeftAccessor;
1817
private static readonly Func<CSharpSyntaxNode, SyntaxToken> OperatorTokenAccessor;
1918
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode> RightAccessor;
2019
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode, CSharpSyntaxNode> WithLeftAccessor;
2120
private static readonly Func<CSharpSyntaxNode, SyntaxToken, CSharpSyntaxNode> WithOperatorTokenAccessor;
2221
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode, CSharpSyntaxNode> WithRightAccessor;
22+
private readonly CSharpSyntaxNode node;
2323
static BinaryPatternSyntaxWrapper()
2424
{
2525
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BinaryPatternSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CasePatternSwitchLabelSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly SwitchLabelSyntax node;
1716
private static readonly Func<SwitchLabelSyntax, CSharpSyntaxNode> PatternAccessor;
1817
private static readonly Func<SwitchLabelSyntax, CSharpSyntaxNode> WhenClauseAccessor;
1918
private static readonly Func<SwitchLabelSyntax, SyntaxToken, SwitchLabelSyntax> WithKeywordAccessor;
2019
private static readonly Func<SwitchLabelSyntax, CSharpSyntaxNode, SwitchLabelSyntax> WithPatternAccessor;
2120
private static readonly Func<SwitchLabelSyntax, CSharpSyntaxNode, SwitchLabelSyntax> WithWhenClauseAccessor;
2221
private static readonly Func<SwitchLabelSyntax, SyntaxToken, SwitchLabelSyntax> WithColonTokenAccessor;
22+
private readonly SwitchLabelSyntax node;
2323
static CasePatternSwitchLabelSyntaxWrapper()
2424
{
2525
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(CasePatternSwitchLabelSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CommonForEachStatementSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly StatementSyntax node;
1716
private static readonly Func<StatementSyntax, SyntaxToken> AwaitKeywordAccessor;
1817
private static readonly Func<StatementSyntax, SyntaxToken> ForEachKeywordAccessor;
1918
private static readonly Func<StatementSyntax, SyntaxToken> OpenParenTokenAccessor;
@@ -28,6 +27,7 @@ namespace StyleCop.Analyzers.Lightup
2827
private static readonly Func<StatementSyntax, ExpressionSyntax, StatementSyntax> WithExpressionAccessor;
2928
private static readonly Func<StatementSyntax, SyntaxToken, StatementSyntax> WithCloseParenTokenAccessor;
3029
private static readonly Func<StatementSyntax, StatementSyntax, StatementSyntax> WithStatementAccessor;
30+
private readonly StatementSyntax node;
3131
static CommonForEachStatementSyntaxWrapper()
3232
{
3333
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(CommonForEachStatementSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ConstantPatternSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly CSharpSyntaxNode node;
1716
private static readonly Func<CSharpSyntaxNode, ExpressionSyntax> ExpressionAccessor;
1817
private static readonly Func<CSharpSyntaxNode, ExpressionSyntax, CSharpSyntaxNode> WithExpressionAccessor;
18+
private readonly CSharpSyntaxNode node;
1919
static ConstantPatternSyntaxWrapper()
2020
{
2121
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ConstantPatternSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationExpressionSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly ExpressionSyntax node;
1716
private static readonly Func<ExpressionSyntax, TypeSyntax> TypeAccessor;
1817
private static readonly Func<ExpressionSyntax, CSharpSyntaxNode> DesignationAccessor;
1918
private static readonly Func<ExpressionSyntax, TypeSyntax, ExpressionSyntax> WithTypeAccessor;
2019
private static readonly Func<ExpressionSyntax, CSharpSyntaxNode, ExpressionSyntax> WithDesignationAccessor;
20+
private readonly ExpressionSyntax node;
2121
static DeclarationExpressionSyntaxWrapper()
2222
{
2323
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(DeclarationExpressionSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationPatternSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly CSharpSyntaxNode node;
1716
private static readonly Func<CSharpSyntaxNode, TypeSyntax> TypeAccessor;
1817
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode> DesignationAccessor;
1918
private static readonly Func<CSharpSyntaxNode, TypeSyntax, CSharpSyntaxNode> WithTypeAccessor;
2019
private static readonly Func<CSharpSyntaxNode, CSharpSyntaxNode, CSharpSyntaxNode> WithDesignationAccessor;
20+
private readonly CSharpSyntaxNode node;
2121
static DeclarationPatternSyntaxWrapper()
2222
{
2323
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(DeclarationPatternSyntaxWrapper));

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DefaultConstraintSyntaxWrapper.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace StyleCop.Analyzers.Lightup
1313
{
1414
internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DefaultConstraintSyntax";
1515
private static readonly Type WrappedType;
16-
private readonly TypeParameterConstraintSyntax node;
1716
private static readonly Func<TypeParameterConstraintSyntax, SyntaxToken> DefaultKeywordAccessor;
1817
private static readonly Func<TypeParameterConstraintSyntax, SyntaxToken, TypeParameterConstraintSyntax> WithDefaultKeywordAccessor;
18+
private readonly TypeParameterConstraintSyntax node;
1919
static DefaultConstraintSyntaxWrapper()
2020
{
2121
WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(DefaultConstraintSyntaxWrapper));

0 commit comments

Comments
 (0)