Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
add652cc
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,发现更多精彩内容 >>
提交
add652cc
编写于
9月 27, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MoveFile moves existing file to root of project when renaming them.
上级
83346efe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
6 deletion
+36
-6
src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
...pTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
+1
-1
src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameFile.cs
...harpTest/CodeActions/MoveType/MoveTypeTests.RenameFile.cs
+22
-0
src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs
src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs
+8
-1
src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.RenameFileEditor.cs
...ings/MoveType/AbstractMoveTypeService.RenameFileEditor.cs
+5
-4
未找到文件。
src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
浏览文件 @
add652cc
...
...
@@ -54,7 +54,7 @@ class Class2 { }";
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsMoveType
)]
[
WorkItem
(
14008
,
"https://github.com/dotnet/roslyn/issues/14008"
)]
public
async
Task
TestFolders
()
public
async
Task
Test
MoveToNewFileWith
Folders
()
{
var
code
=
@"
...
...
src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameFile.cs
浏览文件 @
add652cc
...
...
@@ -33,6 +33,28 @@ class Inner { }
await
TestRenameFileToMatchTypeAsync
(
code
,
expectedDocumentName
);
}
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsMoveType
)]
public
async
Task
TestRenameFileWithFolders
()
{
var
code
=
@"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
<Document Folders=""A\B"">
[||]class Class1
{
class Inner { }
}
</Document>
</Project>
</Workspace>"
;
var
expectedDocumentName
=
"Class1.cs"
;
await
TestRenameFileToMatchTypeAsync
(
code
,
expectedDocumentName
,
destinationDocumentContainers
:
new
[]
{
"A"
,
"B"
});
}
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsMoveType
)]
public
async
Task
TestMissing_TypeNameMatchesFileName_RenameFile
()
{
...
...
src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs
浏览文件 @
add652cc
...
...
@@ -73,7 +73,8 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
string
originalCode
,
string
expectedDocumentName
=
null
,
bool
expectedCodeAction
=
true
,
bool
compareTokens
=
true
)
bool
compareTokens
=
true
,
IList
<
string
>
destinationDocumentContainers
=
null
)
{
using
(
var
workspace
=
await
CreateWorkspaceFromFileAsync
(
originalCode
,
parseOptions
:
null
,
compilationOptions
:
null
))
{
...
...
@@ -96,6 +97,12 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
// the original source document does not exist in the new solution.
var
newSolution
=
oldSolutionAndNewSolution
.
Item2
;
Assert
.
Null
(
newSolution
.
GetDocument
(
oldDocumentId
));
if
(
destinationDocumentContainers
!=
null
)
{
var
newDocument
=
newSolution
.
Projects
.
First
().
Documents
.
First
();
Assert
.
Equal
(
destinationDocumentContainers
,
newDocument
.
Folders
);
}
}
else
{
...
...
src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.RenameFileEditor.cs
浏览文件 @
add652cc
...
...
@@ -26,16 +26,17 @@ internal override Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
/// </summary>
private
IEnumerable
<
CodeActionOperation
>
RenameFileToMatchTypeName
()
{
var
solution
=
SemanticDocument
.
Document
.
Project
.
Solution
;
var
oldDocument
=
SemanticDocument
.
Document
;
var
solution
=
oldDocument
.
Project
.
Solution
;
var
text
=
SemanticDocument
.
Text
;
var
oldDocumentId
=
SemanticDocument
.
Document
.
Id
;
var
newDocumentId
=
DocumentId
.
CreateNewId
(
SemanticDocument
.
Document
.
Project
.
Id
,
FileName
);
var
oldDocumentId
=
old
Document
.
Id
;
var
newDocumentId
=
DocumentId
.
CreateNewId
(
old
Document
.
Project
.
Id
,
FileName
);
// currently, document rename is accomplished by a remove followed by an add.
// the workspace takes care of resolving conflicts if the document name is not unique in the project
// by adding numeric suffixes to the new document being added.
var
newSolution
=
solution
.
RemoveDocument
(
oldDocumentId
);
newSolution
=
newSolution
.
AddDocument
(
newDocumentId
,
FileName
,
text
);
newSolution
=
newSolution
.
AddDocument
(
newDocumentId
,
FileName
,
text
,
oldDocument
.
Folders
);
return
new
CodeActionOperation
[]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录