Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
67160f62
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,发现更多精彩内容 >>
提交
67160f62
编写于
8月 21, 2019
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Exclude unchangeable document from change namespace results
上级
fee56fea
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
3 deletion
+71
-3
src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs
...CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs
+12
-2
src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/SyncNamespaceTests_ChangeNamespace.cs
...tions/SyncNamespace/SyncNamespaceTests_ChangeNamespace.cs
+56
-0
src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs
...actorings/SyncNamespace/AbstractChangeNamespaceService.cs
+3
-1
未找到文件。
src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs
浏览文件 @
67160f62
...
...
@@ -169,7 +169,6 @@ protected async Task TestMoveFileToMatchNamespace(string initialMarkup, List<str
var
changedDocumentIds
=
SolutionUtilities
.
GetChangedDocuments
(
oldSolution
,
newSolution
);
Assert
.
True
(
changedDocumentIds
.
Contains
(
originalDocumentId
),
"original document was not changed."
);
Assert
.
True
(
expectedSourceReference
==
null
||
changedDocumentIds
.
Contains
(
refDocumentId
),
"reference document was not changed."
);
var
modifiedOriginalDocument
=
newSolution
.
GetDocument
(
originalDocumentId
);
var
modifiedOringinalRoot
=
await
modifiedOriginalDocument
.
GetSyntaxRootAsync
();
...
...
@@ -195,8 +194,19 @@ protected async Task TestMoveFileToMatchNamespace(string initialMarkup, List<str
var
actualText
=
(
await
modifiedOriginalDocument
.
GetTextAsync
()).
ToString
();
Assert
.
Equal
(
expectedSourceOriginal
,
actualText
);
if
(
expectedSourceReference
!
=
null
)
if
(
expectedSourceReference
=
=
null
)
{
// there shouldn't be any textual change
if
(
changedDocumentIds
.
Contains
(
refDocumentId
))
{
var
oldRefText
=
(
await
oldSolution
.
GetDocument
(
refDocumentId
).
GetTextAsync
()).
ToString
();
var
newRefText
=
(
await
newSolution
.
GetDocument
(
refDocumentId
).
GetTextAsync
()).
ToString
();
Assert
.
Equal
(
oldRefText
,
newRefText
);
}
}
else
{
Assert
.
True
(
changedDocumentIds
.
Contains
(
refDocumentId
));
var
actualRefText
=
(
await
newSolution
.
GetDocument
(
refDocumentId
).
GetTextAsync
()).
ToString
();
Assert
.
Equal
(
expectedSourceReference
,
actualRefText
);
}
...
...
src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/SyncNamespaceTests_ChangeNamespace.cs
浏览文件 @
67160f62
...
...
@@ -466,6 +466,62 @@ void M1()
await
TestChangeNamespaceAsync
(
code
,
expectedSourceOriginal
,
expectedSourceReference
);
}
[
WorkItem
(
963225
,
"https://dev.azure.com/devdiv/DevDiv/_workitems/edit/963225"
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsSyncNamespace
)]
public
async
Task
ChangeNamespace_WithReferencesInUnchangeableDocument
()
{
var
defaultNamespace
=
"A"
;
var
declaredNamespace
=
"Foo.Bar.Baz"
;
var
documentPath1
=
CreateDocumentFilePath
(
new
[]
{
"B"
,
"C"
},
"File1.cs"
);
var
documentPath2
=
CreateDocumentFilePath
(
Array
.
Empty
<
string
>(),
"File2.cs"
);
var
code
=
$@"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" FilePath=""
{
ProjectFilePath
}
"" RootNamespace=""
{
defaultNamespace
}
"" CommonReferences=""true"">
<Document Folders=""
{
documentPath1
.
folder
}
"" FilePath=""
{
documentPath1
.
filePath
}
"">
namespace [||]
{
declaredNamespace
}
{{
class
Class1
{{
}}
class
Class2
{{
}}
}}
</Document>
<Document Folders=""
{
documentPath2
.
folder
}
"" FilePath=""
{
documentPath2
.
filePath
}
"" CanApplyChange=""false"">
using Foo.Bar.Baz;
namespace Foo
{{
class
RefClass
{{
private
Class1
c1
;
void
M1
()
{{
Bar
.
Baz
.
Class2
c2
=
null
;
}}
}}
}}
</Document>
</Project>
</Workspace>"
;
var
expectedSourceOriginal
=
@"namespace A.B.C
{
class Class1
{
}
class Class2
{
}
}"
;
await
TestChangeNamespaceAsync
(
code
,
expectedSourceOriginal
);
}
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsSyncNamespace
)]
public
async
Task
ChangeNamespace_WithQualifiedReferencesInOtherDocument
()
{
...
...
src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs
浏览文件 @
67160f62
...
...
@@ -188,7 +188,9 @@ await ChangeNamespaceInSingleDocumentAsync(solutionAfterNamespaceChange, documen
ImmutableArray
.
Create
(
declaredNamespace
,
targetNamespace
),
cancellationToken
).
ConfigureAwait
(
false
);
return
await
MergeDiffAsync
(
solutionAfterFirstMerge
,
solutionAfterImportsRemoved
,
cancellationToken
).
ConfigureAwait
(
false
);
var
mergedSolution
=
await
MergeDiffAsync
(
solutionAfterFirstMerge
,
solutionAfterImportsRemoved
,
cancellationToken
).
ConfigureAwait
(
false
);
return
await
mergedSolution
.
ExcludeDisallowedDocumentTextChangesAsync
(
solution
,
cancellationToken
).
ConfigureAwait
(
false
);
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录