-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
49 deletions.
There are no files selected for viewing
94 changes: 47 additions & 47 deletions
94
CodeAnalysis.CSharp.Extensions/Syntax/ConstructorDeclarationSyntaxExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Syntax | ||
{ | ||
using static SyntaxFactory; | ||
using DeclarationSyntax = ConstructorDeclarationSyntax; | ||
|
||
public static class ConstructorDeclarationSyntaxExtensions | ||
{ | ||
public static DeclarationSyntax WithBody(this DeclarationSyntax @this, string bodyStatement) => | ||
@this.WithBody(bodyStatement.ToBlock()); | ||
|
||
public static DeclarationSyntax WithBaseConstructorInitializer(this DeclarationSyntax @this) => | ||
@this.WithInitializer(ConstructorInitializer(SyntaxKind.BaseConstructorInitializer)); | ||
|
||
public static DeclarationSyntax WithBaseConstructorInitializer(this DeclarationSyntax @this, params string[] argumentIdentifiers) => | ||
@this.WithInitializer(ConstructorInitializer(SyntaxKind.BaseConstructorInitializer) | ||
.WithArgumentList(argumentIdentifiers.ToArgumentList())); | ||
|
||
public static DeclarationSyntax WithModifier(this DeclarationSyntax @this, SyntaxKind modifier) => | ||
@this.WithModifiers(modifier.ToTokenList()); | ||
|
||
public static DeclarationSyntax WithModifiers(this DeclarationSyntax @this, params SyntaxKind[] modifiers) => | ||
@this.WithModifiers(modifiers.ToTokenList()); | ||
|
||
public static DeclarationSyntax AddModifier(this DeclarationSyntax @this, SyntaxKind modifier) => | ||
@this.AddModifiers(modifier.ToToken()); | ||
|
||
public static DeclarationSyntax AddModifiers(this DeclarationSyntax @this, params SyntaxKind[] modifiers) => | ||
@this.AddModifiers(modifiers.ToTokens()); | ||
|
||
public static DeclarationSyntax AddAttribute(this DeclarationSyntax @this, AttributeSyntax attribute) => | ||
@this.AddAttributeLists(attribute.ToAttributeList()); | ||
|
||
public static DeclarationSyntax AddAttributes(this DeclarationSyntax @this, params AttributeSyntax[] attributes) => | ||
@this.AddAttributeLists(attributes.ToAttributeList()); | ||
|
||
public static ConstructorDeclarationSyntax WithParameter(this ConstructorDeclarationSyntax @this, string parameterType, string parameterIdentifier) => | ||
@this.WithParameterList((parameterIdentifier, parameterType).ToParameterList()); | ||
|
||
public static ConstructorDeclarationSyntax WithParameters(this ConstructorDeclarationSyntax @this, IEnumerable<KeyValuePair<string, string>> parameters) => | ||
@this.WithParameterList(parameters.ToParameterList()); | ||
|
||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Syntax | ||
{ | ||
using static SyntaxFactory; | ||
using DeclarationSyntax = ConstructorDeclarationSyntax; | ||
|
||
public static class ConstructorDeclarationSyntaxExtensions | ||
{ | ||
public static DeclarationSyntax WithBody(this DeclarationSyntax @this, string bodyStatement) => | ||
@this.WithBody(bodyStatement.ToBlock()); | ||
|
||
public static DeclarationSyntax WithBaseConstructorInitializer(this DeclarationSyntax @this) => | ||
@this.WithInitializer(ConstructorInitializer(SyntaxKind.BaseConstructorInitializer)); | ||
|
||
public static DeclarationSyntax WithBaseConstructorInitializer(this DeclarationSyntax @this, params string[] argumentIdentifiers) => | ||
@this.WithInitializer(ConstructorInitializer(SyntaxKind.BaseConstructorInitializer) | ||
.WithArgumentList(argumentIdentifiers.ToArgumentList())); | ||
|
||
public static DeclarationSyntax WithModifier(this DeclarationSyntax @this, SyntaxKind modifier) => | ||
@this.WithModifiers(modifier.ToTokenList()); | ||
|
||
public static DeclarationSyntax WithModifiers(this DeclarationSyntax @this, params SyntaxKind[] modifiers) => | ||
@this.WithModifiers(modifiers.ToTokenList()); | ||
|
||
public static DeclarationSyntax AddModifier(this DeclarationSyntax @this, SyntaxKind modifier) => | ||
@this.AddModifiers(modifier.ToToken()); | ||
|
||
public static DeclarationSyntax AddModifiers(this DeclarationSyntax @this, params SyntaxKind[] modifiers) => | ||
@this.AddModifiers(modifiers.ToTokens()); | ||
|
||
public static DeclarationSyntax AddAttribute(this DeclarationSyntax @this, AttributeSyntax attribute) => | ||
@this.AddAttributeLists(attribute.ToAttributeList()); | ||
|
||
public static DeclarationSyntax AddAttributes(this DeclarationSyntax @this, params AttributeSyntax[] attributes) => | ||
@this.AddAttributeLists(attributes.ToAttributeList()); | ||
|
||
public static DeclarationSyntax WithParameter(this DeclarationSyntax @this, string parameterType, string parameterIdentifier) => | ||
@this.WithParameterList((parameterIdentifier, parameterType).ToParameterList()); | ||
|
||
public static DeclarationSyntax WithParameters(this DeclarationSyntax @this, IEnumerable<KeyValuePair<string, string>> parameters) => | ||
@this.WithParameterList(parameters.ToParameterList()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters