Переполнение стека в сборке. Пытаюсь найти решение
Всем добрый день! Есть вот такая строка. Нужно вставить строку между фигурными скобками, если эти скобки относиться к методу Судя по коду видно, что я хочу найти рекурсивные функции и посчитать их вызовы, что бы они не переполнили стек
using System;
using System.IO;
using System.Text.RegularExpressions;
namespace HelloWorld
{
class Program
{
int stackCount = 0;
static void Main(string[] args)
{
string str = @"using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(""Hello World!234""); // Hello World
Foo();
}
static int Main(string[] args)
{
Console.WriteLine(""Hello World!234""); // Hello World
Foo();
}
static void Foo()
{
Foo();
}
}
}
";
string insertStr = "stackCount++;if(stackCount > 1500) throw new Exception()";
Regex regex = new Regex("\\s.?/*");
MatchCollection match = regex.Matches(str);
foreach (var item in match)
{
Console.WriteLine(item);
}
}
}
}