forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptResult.cs
More file actions
42 lines (33 loc) · 1.11 KB
/
ScriptResult.cs
File metadata and controls
42 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Runtime.ExceptionServices;
namespace ScriptCs.Contracts
{
public class ScriptResult
{
public object ReturnValue { get; set; }
public ExceptionDispatchInfo ExecuteExceptionInfo { get; set; }
public ExceptionDispatchInfo CompileExceptionInfo { get; set; }
public bool IsPendingClosingChar { get; set; }
public char? ExpectingClosingChar { get; set; }
public void UpdateClosingExpectation(Exception ex)
{
Guard.AgainstNullArgument("ex", ex);
var message = ex.Message;
char? closingChar = null;
if (message.Contains("CS1026: ) expected"))
{
closingChar = ')';
}
else if (message.Contains("CS1513: } expected"))
{
closingChar = '}';
}
else if (message.Contains("CS1003: Syntax error, ']' expected"))
{
closingChar = ']';
}
ExpectingClosingChar = closingChar;
IsPendingClosingChar = closingChar.HasValue;
}
}
}