Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
786eeffd
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,发现更多精彩内容 >>
提交
786eeffd
编写于
1月 11, 2016
作者:
A
Artur Spychaj
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7811 from drognanar/issue7645
Construct submissions with empty file path in VS
上级
98447e47
4270c02d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
3 deletion
+43
-3
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
+32
-0
src/EditorFeatures/Test/Workspaces/TestHostDocument.cs
src/EditorFeatures/Test/Workspaces/TestHostDocument.cs
+2
-1
src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs
...kspaces/Core/Portable/Workspace/Solution/DocumentState.cs
+9
-2
未找到文件。
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
浏览文件 @
786eeffd
...
...
@@ -202,6 +202,38 @@ class D { }
}
}
[
Fact
]
public
async
void
TestAddedSubmissionParseTreeHasEmptyFilePath
()
{
using
(
var
workspace
=
CreateWorkspace
())
{
var
document1
=
new
TestHostDocument
(
"var x = 1;"
,
displayName
:
"Sub1"
,
sourceCodeKind
:
SourceCodeKind
.
Script
);
var
project1
=
new
TestHostProject
(
workspace
,
document1
,
name
:
"Submission"
);
var
document2
=
new
TestHostDocument
(
"var x = 2;"
,
displayName
:
"Sub2"
,
sourceCodeKind
:
SourceCodeKind
.
Script
,
filePath
:
"a.csx"
);
var
project2
=
new
TestHostProject
(
workspace
,
document2
,
name
:
"Script"
);
workspace
.
AddTestProject
(
project1
);
workspace
.
AddTestProject
(
project2
);
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
);
// Check that a parse tree for a submission has an empty file path.
SyntaxTree
tree1
=
await
workspace
.
CurrentSolution
.
GetProjectState
(
project1
.
Id
)
.
GetDocumentState
(
document1
.
Id
)
.
GetSyntaxTreeAsync
(
CancellationToken
.
None
);
Assert
.
Equal
(
""
,
tree1
.
FilePath
);
// Check that a parse tree for a script does not have an empty file path.
SyntaxTree
tree2
=
await
workspace
.
CurrentSolution
.
GetProjectState
(
project2
.
Id
)
.
GetDocumentState
(
document2
.
Id
)
.
GetSyntaxTreeAsync
(
CancellationToken
.
None
);
Assert
.
Equal
(
"a.csx"
,
tree2
.
FilePath
);
}
}
private
static
async
Task
VerifyRootTypeNameAsync
(
TestWorkspace
workspaceSnapshotBuilder
,
string
typeName
)
{
var
currentSnapshot
=
workspaceSnapshotBuilder
.
CurrentSolution
;
...
...
src/EditorFeatures/Test/Workspaces/TestHostDocument.cs
浏览文件 @
786eeffd
...
...
@@ -140,7 +140,7 @@ public TextLoader Loader
_loader
=
new
TestDocumentLoader
(
this
);
}
public
TestHostDocument
(
string
text
=
""
,
string
displayName
=
""
,
SourceCodeKind
sourceCodeKind
=
SourceCodeKind
.
Regular
,
DocumentId
id
=
null
)
public
TestHostDocument
(
string
text
=
""
,
string
displayName
=
""
,
SourceCodeKind
sourceCodeKind
=
SourceCodeKind
.
Regular
,
DocumentId
id
=
null
,
string
filePath
=
null
)
{
_exportProvider
=
TestExportProvider
.
ExportProviderWithCSharpAndVisualBasic
;
_id
=
id
;
...
...
@@ -148,6 +148,7 @@ public TestHostDocument(string text = "", string displayName = "", SourceCodeKin
_name
=
displayName
;
_sourceCodeKind
=
sourceCodeKind
;
_loader
=
new
TestDocumentLoader
(
this
);
_filePath
=
filePath
;
}
internal
void
SetProject
(
TestHostProject
project
)
...
...
src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs
浏览文件 @
786eeffd
...
...
@@ -87,10 +87,17 @@ internal bool SupportsSyntaxTree
}
// This is the string used to represent the FilePath property on a SyntaxTree object.
// if the document does not yet have a file path, use the document's name instead.
// if the document does not yet have a file path, use the document's name instead in regular code
// or an empty string in script code.
private
static
string
GetSyntaxTreeFilePath
(
DocumentInfo
info
)
{
return
info
.
FilePath
??
info
.
Name
;
if
(
info
.
FilePath
!=
null
)
{
return
info
.
FilePath
;
}
return
info
.
SourceCodeKind
==
SourceCodeKind
.
Regular
?
info
.
Name
:
""
;
}
private
static
ValueSource
<
TreeAndVersion
>
CreateLazyFullyParsedTree
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录