private string GetValidationResult(Stream requestStream) { var compiler = new CSharpValidator(new CSharpCompilationProvider()); var serializer = new JavaScriptSerializer(); SourceCode sourceCode; using (var reader = new StreamReader(requestStream)) { var foo = reader.ReadToEnd(); sourceCode = serializer.Deserialize<SourceCode>(foo); } var errors = compiler.GetCompilationErrors(sourceCode) .Where(x => x.Info.Severity > DiagnosticSeverity.Warning) .Select(x => new { Location = x.Location.GetLineSpan(true), Message = x.Info.GetMessage(), }); return serializer.Serialize(new { status = "ok", data = errors }); }
private string GetValidationResult(Stream requestStream) { var compiler = new CSharpValidator(new CSharpCompilationProvider()); var serializer = new JavaScriptSerializer(); SourceCode sourceCode; using (var reader = new StreamReader(requestStream)) { var foo = reader.ReadToEnd(); sourceCode = serializer.Deserialize <SourceCode>(foo); } var errors = compiler.GetCompilationErrors(sourceCode) .Where(x => x.Info.Severity > DiagnosticSeverity.Warning) .Select(x => new { Location = x.Location.GetLineSpan(true), Message = x.Info.GetMessage(), }); return(serializer.Serialize(new { status = "ok", data = errors })); }
public HomeController(IPostRepository contentRepository) { db = contentRepository; compiler = new CSharpValidator(new CSharpCompilationProvider()); }