Add more resilience to regex and C# compilation