Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.
public static class ClassDeclarationSyntaxExtensions
ClassDeclarationSyntax AddGeneratedCodeAttribute(this ClassDeclarationSyntax classDeclaration, string toolName, string version)Summary: Adds a
System.CodeDom.Compiler.GeneratedCodeAttributeto the class declaration.Parameters:
classDeclaration- The class declaration to modify.
toolName- The name of the code generation tool.
version- The version of the code generation tool.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntaxwith the attribute added.
ClassDeclarationSyntax AddSuppressMessageAttribute(this ClassDeclarationSyntax classDeclaration, SuppressMessageAttribute suppressMessage)Summary: Adds a
System.Diagnostics.CodeAnalysis.SuppressMessageAttributeto the class declaration.Parameters:
classDeclaration- The class declaration to modify.
suppressMessage- The suppress message attribute to add.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntaxwith the attribute added.
Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax.
public static class CompilationUnitSyntaxExtensions
CompilationUnitSyntax AddUsingStatements(this CompilationUnitSyntax compilationUnit, string[] usingStatements)Summary: Adds using statements to the compilation unit and sorts them.
Parameters:
compilationUnit- The compilation unit to modify.
usingStatements- The array of using statement strings to add.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntaxwith the using statements added and sorted.
Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.EnumDeclarationSyntax.
public static class EnumDeclarationSyntaxExtensions
EnumDeclarationSyntax AddFlagAttribute(this EnumDeclarationSyntax enumDeclaration)Summary: Adds a
System.FlagsAttributeto the enum declaration.Parameters:
enumDeclaration- The enum declaration to modify.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.EnumDeclarationSyntaxwith the attribute added.
EnumDeclarationSyntax AddSuppressMessageAttribute(this EnumDeclarationSyntax enumDeclaration, SuppressMessageAttribute suppressMessage)Summary: Adds a
System.Diagnostics.CodeAnalysis.SuppressMessageAttributeto the enum declaration.Parameters:
enumDeclaration- The enum declaration to modify.
suppressMessage- The suppress message attribute to add.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.EnumDeclarationSyntaxwith the attribute added.
bool HasAttributeOfAttributeType(this EnumDeclarationSyntax enumDeclaration, Type attributeType)Summary: Determines whether the enum declaration has an attribute of the specified type.
Parameters:
enumDeclaration- The enum declaration to check.
attributeType- The type of attribute to search for.Returns:
trueif the enum has an attribute of the specified type; otherwise,false.
Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.InterfaceDeclarationSyntax.
public static class InterfaceDeclarationSyntaxExtensions
InterfaceDeclarationSyntax AddGeneratedCodeAttribute(this InterfaceDeclarationSyntax interfaceDeclaration, string toolName, string version)Summary: Adds a
System.CodeDom.Compiler.GeneratedCodeAttributeto the interface declaration.Parameters:
interfaceDeclaration- The interface declaration to modify.
toolName- The name of the code generation tool.
version- The version of the code generation tool.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.InterfaceDeclarationSyntaxwith the attribute added.
Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.
public static class MethodDeclarationSyntaxExtensions
MethodDeclarationSyntax AddSuppressMessageAttribute(this MethodDeclarationSyntax methodDeclaration, SuppressMessageAttribute suppressMessage)Summary: Adds a
System.Diagnostics.CodeAnalysis.SuppressMessageAttributeto the method declaration.Parameters:
methodDeclaration- The method declaration to modify.
suppressMessage- The suppress message attribute to add.Returns: A new
Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntaxwith the attribute added.
Extension methods for Microsoft.CodeAnalysis.SyntaxNode.
public static class SyntaxNodeExtensions
string[] GetUsedUsingStatements(this SyntaxNode syntaxNode)Summary: Gets all using directive statements from the syntax node.
Parameters:
syntaxNode- The syntax node to search.Returns: An array of using directive strings.
string[] GetUsedUsingStatementsWithoutAlias(this SyntaxNode syntaxNode)Summary: Gets all using directive statements from the syntax node, excluding those with aliases.
Parameters:
syntaxNode- The syntax node to search.Returns: An array of using directive strings without aliases.
IEnumerable<T> Select(this SyntaxNode syntaxNode)Summary: Selects all descendant nodes of type
Tfrom the syntax node.Parameters:
syntaxNode- The syntax node to search.Returns: An enumerable collection of syntax nodes of type
T.
T[] SelectToArray(this SyntaxNode syntaxNode)Summary: Selects all descendant nodes of type
Tfrom the syntax node and returns them as an array.Parameters:
syntaxNode- The syntax node to search.Returns: An array of syntax nodes of type
T.
Extension methods for Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.
public static class UsingDirectiveSyntaxExtensions