Коммит
867e7e0a5d
|
@ -41,6 +41,8 @@ namespace Microsoft.Spark.CSharp
|
|||
private readonly SparkContext sc;
|
||||
private readonly SparkCLRHost host;
|
||||
|
||||
private readonly ParseOptions options;
|
||||
|
||||
public RoslynScriptEngine(SparkConf sparkConf, SparkContext sc)
|
||||
{
|
||||
this.sparkConf = sparkConf;
|
||||
|
@ -54,6 +56,8 @@ namespace Microsoft.Spark.CSharp
|
|||
var sparkLocalDir = sparkConf.Get("spark.local.dir", Path.GetTempPath());
|
||||
compilationDumpDirectory = Path.Combine(sparkLocalDir, Path.GetRandomFileName());
|
||||
Directory.CreateDirectory(compilationDumpDirectory);
|
||||
|
||||
options = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Parse, SourceCodeKind.Script);
|
||||
}
|
||||
|
||||
internal Script<object> CreateScript(string code)
|
||||
|
@ -103,7 +107,7 @@ namespace Microsoft.Spark.CSharp
|
|||
{
|
||||
message.Append("[").Append(diagnostic.Severity).Append("] ").Append(": ").Append(diagnostic).Append("\r\n");
|
||||
}
|
||||
return new ScriptResult(null, null, new Exception(message.ToString()));
|
||||
return new ScriptResult(compilationException: new Exception(message.ToString()));
|
||||
}
|
||||
|
||||
var compilationDump = DumpCompilation(script.GetCompilation());
|
||||
|
@ -135,11 +139,11 @@ namespace Microsoft.Spark.CSharp
|
|||
}
|
||||
}
|
||||
previousState = endState;
|
||||
return new ScriptResult(endState.ReturnValue, null, null);
|
||||
return new ScriptResult(returnValue: endState.ReturnValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScriptResult(null, e, null);
|
||||
return new ScriptResult(executionException: e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +169,6 @@ namespace Microsoft.Spark.CSharp
|
|||
/// </summary>
|
||||
internal bool IsCompleteSubmission(string code)
|
||||
{
|
||||
var options = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Diagnose, SourceCodeKind.Script);
|
||||
SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options);
|
||||
return SyntaxFactory.IsCompleteSubmission(syntaxTree);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ namespace Microsoft.Spark.CSharp
|
|||
IsCompleteSubmission = true;
|
||||
}
|
||||
|
||||
public object ReturnValue { get; private set; }
|
||||
|
||||
public bool IsCompleteSubmission { get; private set; }
|
||||
|
||||
public object ReturnValue { get; private set; }
|
||||
|
||||
public ExceptionDispatchInfo ExecuteExceptionInfo { get; private set; }
|
||||
|
||||
public ExceptionDispatchInfo CompileExceptionInfo { get; private set; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче