/// <summary>
        /// Read the given file and apply the CSharp Syntax Walker on the resulting syntactic tree.
        /// </summary>
        /// <param name="file">The file to parse.</param>
        /// <param name="walker">The walker to apply.</param>
        public static void Read(string file, CSharpSyntaxWalker walker)
        {
            if (walker == null)
            {
                throw new ArgumentNullException(nameof(walker), $"The argument {nameof(walker)} was null.");
            }

            walker.Visit(Parse(file).GetRoot());
        }
 public static bool SafeVisit(this CSharpSyntaxWalker syntaxWalker, SyntaxNode syntaxNode)
 {
     try
     {
         syntaxWalker.Visit(syntaxNode);
         return(true);
     }
     catch (InsufficientExecutionStackException)
     {
         // Roslyn walker overflows the stack when the depth of the call is around 2050.
         // See https://github.com/SonarSource/sonar-dotnet/issues/2115
         return(false);
     }
 }