Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
931fdf92
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
931fdf92
编写于
2月 07, 2017
作者:
F
filipw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
applied review feedback
上级
5fbe48ba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
13 deletion
+20
-13
src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs
src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs
+2
-2
src/Scripting/Core/Script.cs
src/Scripting/Core/Script.cs
+11
-4
src/Scripting/Core/ScriptOptions.cs
src/Scripting/Core/ScriptOptions.cs
+2
-1
src/Scripting/CoreTest/ScriptOptionsTests.cs
src/Scripting/CoreTest/ScriptOptionsTests.cs
+5
-6
未找到文件。
src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs
浏览文件 @
931fdf92
...
...
@@ -178,7 +178,7 @@ private int RunScript(ScriptOptions options, string code, ErrorLogger errorLogge
var
globals
=
new
CommandLineScriptGlobals
(
_console
.
Out
,
_objectFormatter
);
globals
.
Args
.
AddRange
(
_compiler
.
Arguments
.
ScriptArguments
);
var
script
=
Script
.
CreateInitialScript
<
int
>(
_scriptCompiler
,
SourceText
.
From
(
code
??
string
.
Empty
),
options
,
globals
.
GetType
(),
assemblyLoaderOpt
:
null
);
var
script
=
Script
.
CreateInitialScript
<
int
>(
_scriptCompiler
,
SourceText
.
From
(
code
),
options
,
globals
.
GetType
(),
assemblyLoaderOpt
:
null
);
try
{
return
script
.
RunAsync
(
globals
,
cancellationToken
).
Result
.
ReturnValue
;
...
...
@@ -199,7 +199,7 @@ private void RunInteractiveLoop(ScriptOptions options, string initialScriptCodeO
if
(
initialScriptCodeOpt
!=
null
)
{
var
script
=
Script
.
CreateInitialScript
<
object
>(
_scriptCompiler
,
SourceText
.
From
(
initialScriptCodeOpt
??
string
.
Empty
),
options
,
globals
.
GetType
(),
assemblyLoaderOpt
:
null
);
var
script
=
Script
.
CreateInitialScript
<
object
>(
_scriptCompiler
,
SourceText
.
From
(
initialScriptCodeOpt
),
options
,
globals
.
GetType
(),
assemblyLoaderOpt
:
null
);
BuildAndRun
(
script
,
globals
,
ref
state
,
ref
options
,
displayResult
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Scripting/Core/Script.cs
浏览文件 @
931fdf92
...
...
@@ -105,16 +105,23 @@ internal static Script<T> CreateInitialScript<T>(ScriptCompiler compiler, Source
/// <summary>
/// Continues the script with given code snippet.
/// </summary>
public
Script
<
TResult
>
ContinueWith
<
TResult
>(
string
code
,
ScriptOptions
options
=
null
)
=>
new
Script
<
TResult
>(
Compiler
,
Builder
,
SourceText
.
From
(
code
??
""
,
options
?.
FileEncoding
??
Options
.
FileEncoding
),
options
??
InheritOptions
(
Options
),
GlobalsType
,
this
);
public
Script
<
TResult
>
ContinueWith
<
TResult
>(
string
code
,
ScriptOptions
options
=
null
)
{
options
=
options
??
InheritOptions
(
Options
);
return
new
Script
<
TResult
>(
Compiler
,
Builder
,
SourceText
.
From
(
code
??
""
,
options
.
FileEncoding
),
options
,
GlobalsType
,
this
);
}
/// <summary>
/// Continues the script with given <see cref="Stream"/> representing code.
/// </summary>
/// <exception cref="ArgumentNullException">Stream is null.</exception>
/// <exception cref="ArgumentException">Stream is not readable or seekable.</exception>
public
Script
<
TResult
>
ContinueWith
<
TResult
>(
Stream
code
,
ScriptOptions
options
=
null
)
=>
new
Script
<
TResult
>(
Compiler
,
Builder
,
SourceText
.
From
(
code
,
options
?.
FileEncoding
??
Options
.
FileEncoding
),
options
??
InheritOptions
(
Options
),
GlobalsType
,
this
);
public
Script
<
TResult
>
ContinueWith
<
TResult
>(
Stream
code
,
ScriptOptions
options
=
null
)
{
if
(
code
==
null
)
throw
new
ArgumentNullException
(
nameof
(
code
));
options
=
options
??
InheritOptions
(
Options
);
return
new
Script
<
TResult
>(
Compiler
,
Builder
,
SourceText
.
From
(
code
,
options
.
FileEncoding
),
options
,
GlobalsType
,
this
);
}
private
static
ScriptOptions
InheritOptions
(
ScriptOptions
previous
)
{
...
...
src/Scripting/Core/ScriptOptions.cs
浏览文件 @
931fdf92
...
...
@@ -100,7 +100,8 @@ private static ImmutableArray<MetadataReference> GetDefaultMetadataReferences()
public
bool
EmitDebugInformation
{
get
;
private
set
;
}
=
false
;
/// <summary>
/// Specifies the encoding to be used when debugging scripts loaded from a file, or that will be saved to a file for debugging purposes.
/// Specifies the encoding to be used when debugging scripts loaded from a file, or saved to a file for debugging purposes.
/// If it's null, the compiler will attempt to detect the necessary encoding for debugging
/// </summary>
public
Encoding
FileEncoding
{
get
;
private
set
;
}
...
...
src/Scripting/CoreTest/ScriptOptionsTests.cs
浏览文件 @
931fdf92
...
...
@@ -151,13 +151,12 @@ public void WithImports_Errors()
options
.
WithImports
(
".blah"
);
}
[
Theory
]
[
InlineData
(
true
)]
[
InlineData
(
false
)]
public
void
WithEmitDebugInformation_SetsEmitDebugInformation
(
bool
emitDebugInformation
)
[
Fact
]
public
void
WithEmitDebugInformation_SetsEmitDebugInformation
()
{
var
options
=
ScriptOptions
.
Default
.
WithEmitDebugInformation
(
emitDebugInformation
);
Assert
.
Equal
(
emitDebugInformation
,
options
.
EmitDebugInformation
);
Assert
.
True
(
ScriptOptions
.
Default
.
WithEmitDebugInformation
(
true
).
EmitDebugInformation
);
Assert
.
False
(
ScriptOptions
.
Default
.
WithEmitDebugInformation
(
false
).
EmitDebugInformation
);
Assert
.
False
(
ScriptOptions
.
Default
.
EmitDebugInformation
);
}
[
Fact
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录