Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4a2cd9cf
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,发现更多精彩内容 >>
提交
4a2cd9cf
编写于
1月 08, 2020
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Exclude changes to unchangeable documents when applied in VS workspace
上级
feddb18e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
25 deletion
+37
-25
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs
...Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs
+2
-0
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+2
-1
src/Workspaces/Core/Portable/CodeActions/CodeAction.cs
src/Workspaces/Core/Portable/CodeActions/CodeAction.cs
+1
-1
src/Workspaces/Core/Portable/Workspace/Solution/ProjectChanges.cs
...spaces/Core/Portable/Workspace/Solution/ProjectChanges.cs
+5
-4
src/Workspaces/Core/Portable/Workspace/Solution/TextDocument.cs
...rkspaces/Core/Portable/Workspace/Solution/TextDocument.cs
+2
-2
src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs
...ces/Core/Portable/Workspace/Solution/TextDocumentState.cs
+7
-3
src/Workspaces/Core/Portable/Workspace/Workspace.cs
src/Workspaces/Core/Portable/Workspace/Workspace.cs
+17
-13
src/Workspaces/CoreTestUtilities/SolutionUtilities.cs
src/Workspaces/CoreTestUtilities/SolutionUtilities.cs
+1
-1
未找到文件。
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs
浏览文件 @
4a2cd9cf
...
...
@@ -72,6 +72,8 @@ protected override void OnDocumentClosing(DocumentId documentId)
}
}
internal
override
bool
IgnoreUnchangeableDocumentsWhenApplyingChanges
=>
true
;
/// <summary>
/// Returns the hierarchy for a given project.
/// </summary>
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
4a2cd9cf
...
...
@@ -378,7 +378,8 @@ public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
var
projectChanges
=
newSolution
.
GetChanges
(
currentSolution
).
GetProjectChanges
().
ToList
();
// first make sure we can edit the document we will be updating (check them out from source control, etc)
var
changedDocs
=
projectChanges
.
SelectMany
(
pd
=>
pd
.
GetChangedDocuments
(
true
).
Concat
(
pd
.
GetChangedAdditionalDocuments
())).
Where
(
CanApplyChange
).
ToList
();
var
changedDocs
=
projectChanges
.
SelectMany
(
pd
=>
pd
.
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
true
).
Concat
(
pd
.
GetChangedAdditionalDocuments
()))
.
Where
(
CanApplyChange
).
ToList
();
if
(
changedDocs
.
Count
>
0
)
{
this
.
EnsureEditableDocuments
(
changedDocs
);
...
...
src/Workspaces/Core/Portable/CodeActions/CodeAction.cs
浏览文件 @
4a2cd9cf
...
...
@@ -225,7 +225,7 @@ protected async Task<Solution> PostProcessChangesAsync(Solution changedSolution,
// process changed projects
foreach
(
var
projectChanges
in
solutionChanges
.
GetProjectChanges
())
{
var
documentsToProcess
=
projectChanges
.
GetChangedDocuments
(
true
).
Concat
(
var
documentsToProcess
=
projectChanges
.
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
true
).
Concat
(
projectChanges
.
GetAddedDocuments
());
foreach
(
var
documentId
in
documentsToProcess
)
...
...
src/Workspaces/Core/Portable/Workspace/Solution/ProjectChanges.cs
浏览文件 @
4a2cd9cf
...
...
@@ -132,9 +132,7 @@ public IEnumerable<DocumentId> GetAddedAnalyzerConfigDocuments()
/// </summary>
/// <returns></returns>
public
IEnumerable
<
DocumentId
>
GetChangedDocuments
()
{
return
GetChangedDocuments
(
false
);
}
=>
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
false
,
ignoreUnchangeableDocuments
:
false
);
/// <summary>
/// Get Changed Documents:
...
...
@@ -145,6 +143,9 @@ public IEnumerable<DocumentId> GetChangedDocuments()
/// <param name="onlyGetDocumentsWithTextChanges"></param>
/// <returns></returns>
public
IEnumerable
<
DocumentId
>
GetChangedDocuments
(
bool
onlyGetDocumentsWithTextChanges
)
=>
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
,
ignoreUnchangeableDocuments
:
false
);
internal
IEnumerable
<
DocumentId
>
GetChangedDocuments
(
bool
onlyGetDocumentsWithTextChanges
,
bool
ignoreUnchangeableDocuments
)
{
foreach
(
var
id
in
_newProject
.
DocumentIds
)
{
...
...
@@ -155,7 +156,7 @@ public IEnumerable<DocumentId> GetChangedDocuments(bool onlyGetDocumentsWithText
{
if
(
onlyGetDocumentsWithTextChanges
)
{
if
(
newState
.
HasTextChanged
(
oldState
))
if
(
newState
.
HasTextChanged
(
oldState
,
ignoreUnchangeableDocuments
))
yield
return
id
;
}
else
...
...
src/Workspaces/Core/Portable/Workspace/Solution/TextDocument.cs
浏览文件 @
4a2cd9cf
...
...
@@ -129,9 +129,9 @@ internal virtual bool HasInfoChanged(TextDocument otherTextDocument)
/// <summary>
/// True if the text of the document change.
/// </summary>
internal
bool
HasTextChanged
(
TextDocument
otherTextDocument
)
internal
bool
HasTextChanged
(
TextDocument
otherTextDocument
,
bool
ignoreUnchangeableDocument
)
{
return
State
.
HasTextChanged
(
otherTextDocument
.
State
);
return
State
.
HasTextChanged
(
otherTextDocument
.
State
,
ignoreUnchangeableDocument
);
}
}
}
src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs
浏览文件 @
4a2cd9cf
...
...
@@ -375,10 +375,14 @@ public virtual async Task<VersionStamp> GetTopLevelChangeTextVersionAsync(Cancel
return
textAndVersion
.
Version
;
}
public
bool
HasTextChanged
(
TextDocumentState
oldState
)
public
bool
HasTextChanged
(
TextDocumentState
oldState
,
bool
ignoreUnchangeableDocument
)
{
return
oldState
.
sourceText
!=
sourceText
||
oldState
.
TextAndVersionSource
!=
TextAndVersionSource
;
if
(
ignoreUnchangeableDocument
&&
!
oldState
.
CanApplyChange
())
{
return
false
;
}
return
oldState
.
TextAndVersionSource
!=
TextAndVersionSource
;
}
public
bool
HasInfoChanged
(
TextDocumentState
oldState
)
...
...
src/Workspaces/Core/Portable/Workspace/Workspace.cs
浏览文件 @
4a2cd9cf
...
...
@@ -52,6 +52,8 @@ public abstract partial class Workspace : IDisposable
internal
bool
TestHookPartialSolutionsDisabled
{
get
;
set
;
}
internal
virtual
bool
IgnoreUnchangeableDocumentsWhenApplyingChanges
{
get
;
}
=
false
;
private
Action
<
string
>?
_testMessageLogger
;
/// <summary>
...
...
@@ -1231,12 +1233,23 @@ private void CheckAllowedProjectChanges(ProjectChanges projectChanges)
throw
new
NotSupportedException
(
WorkspacesResources
.
Changing_document_property_is_not_supported
);
}
if
(!
this
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
&&
projectChanges
.
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
true
).
Any
())
var
changedDocumentIds
=
projectChanges
.
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
true
,
IgnoreUnchangeableDocumentsWhenApplyingChanges
).
ToImmutableArray
();
if
(!
this
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
&&
changedDocumentIds
.
Length
>
0
)
{
throw
new
NotSupportedException
(
WorkspacesResources
.
Changing_documents_is_not_supported
);
}
// Checking for unchangeable documents will only be done if we were asked not to ignore them.
foreach
(
var
documentId
in
changedDocumentIds
)
{
var
document
=
projectChanges
.
OldProject
.
GetDocumentState
(
documentId
)
??
projectChanges
.
NewProject
.
GetDocumentState
(
documentId
)!;
if
(!
document
.
CanApplyChange
())
{
throw
new
NotSupportedException
(
string
.
Format
(
WorkspacesResources
.
Changing_document_0_is_not_supported
,
document
.
FilePath
??
document
.
Name
));
}
}
if
(
projectChanges
.
GetAddedAdditionalDocuments
().
Any
()
&&
!
this
.
CanApplyChange
(
ApplyChangesKind
.
AddAdditionalDocument
))
{
throw
new
NotSupportedException
(
WorkspacesResources
.
Adding_additional_documents_is_not_supported
);
...
...
@@ -1296,15 +1309,6 @@ private void CheckAllowedProjectChanges(ProjectChanges projectChanges)
{
throw
new
NotSupportedException
(
WorkspacesResources
.
Removing_analyzer_references_is_not_supported
);
}
foreach
(
var
documentId
in
projectChanges
.
GetChangedDocuments
())
{
var
document
=
projectChanges
.
OldProject
.
GetDocumentState
(
documentId
)
??
projectChanges
.
NewProject
.
GetDocumentState
(
documentId
)!;
if
(!
document
.
CanApplyChange
())
{
throw
new
NotSupportedException
(
string
.
Format
(
WorkspacesResources
.
Changing_document_0_is_not_supported
,
document
.
FilePath
??
document
.
Name
));
}
}
}
protected
virtual
bool
CanApplyCompilationOptionChange
(
CompilationOptions
oldOptions
,
CompilationOptions
newOptions
,
Project
project
)
...
...
@@ -1452,8 +1456,8 @@ protected virtual void ApplyProjectChanges(ProjectChanges projectChanges)
var
oldDoc
=
projectChanges
.
OldProject
.
GetDocument
(
documentId
)!;
var
newDoc
=
projectChanges
.
NewProject
.
GetDocument
(
documentId
)!;
// update text if
changed
if
(
newDoc
.
HasTextChanged
(
oldDoc
))
// update text if
it's changed (unless it's unchangeable and we were asked to exclude them)
if
(
newDoc
.
HasTextChanged
(
oldDoc
,
IgnoreUnchangeableDocumentsWhenApplyingChanges
))
{
// What we'd like to do here is figure out what actual text changes occurred and pass them on to the host.
// However, since it is likely that the change was done by replacing the syntax tree, getting the actual text changes is non trivial.
...
...
src/Workspaces/CoreTestUtilities/SolutionUtilities.cs
浏览文件 @
4a2cd9cf
...
...
@@ -70,7 +70,7 @@ public static IEnumerable<DocumentId> GetTextChangedDocuments(Solution oldSoluti
var
projectsDifference
=
GetChangedProjectChanges
(
oldSolution
,
newSolution
);
foreach
(
var
projectDifference
in
projectsDifference
)
{
changedDocuments
.
AddRange
(
projectDifference
.
GetChangedDocuments
(
true
));
changedDocuments
.
AddRange
(
projectDifference
.
GetChangedDocuments
(
onlyGetDocumentsWithTextChanges
:
true
));
}
return
changedDocuments
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录