Checks for Static modification in method syntax using Roslyn. - CSharp Microsoft.CodeAnalysis

CSharp examples for Microsoft.CodeAnalysis:Roslyn

Description

Checks for Static modification in method syntax using Roslyn.

Demo Code


using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;

public class Main{
        /// <summary>
        /// Checks for Static modification in method syntax.
        /// </summary>
        /// <param name="methodSyntax"></param>
        /// <returns></returns>
        public static bool IsStatic(this MethodDeclarationSyntax methodSyntax)
        {//  www  . j  a va 2 s .  c  o  m
            return methodSyntax.Modifiers.Any(SyntaxKind.StaticKeyword);
        }
}

Related Tutorials