public void Parse() { GeneratedTemplateCode = string.Empty; using (var writer = new StringWriter()) { GeneratorResults = TemplateCompiler.GenerateCode(_document, writer); var generatedCode = writer.ToString(); generatedCode = Regex.Replace(generatedCode, "//.*", string.Empty); generatedCode = Regex.Replace(generatedCode, "#.*", string.Empty); GeneratedTemplateCode = generatedCode.Trim(); RazorSyntaxTree = new RazorSyntaxTreeVisualizer().Visualize(GeneratorResults.Document); } if (GeneratorResults == null || !GeneratorResults.Success) { if (GeneratorResults != null) { var viewModels = GeneratorResults.ParserErrors.Select(x => new RazorPadRazorError(x)); Errors = new ObservableCollection <RazorPadError>(viewModels); } } }