Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1e20b0a3
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,发现更多精彩内容 >>
提交
1e20b0a3
编写于
6月 28, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use simple usings
上级
21272885
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
111 addition
and
118 deletion
+111
-118
src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
.../Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
+6
-6
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
...ncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
+50
-51
src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
...lementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
+19
-20
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
...Studio/Core/Def/Implementation/Venus/ContainedDocument.cs
+21
-24
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpNavigateTo.cs
...tegrationTest/IntegrationTests/CSharp/CSharpNavigateTo.cs
+15
-17
未找到文件。
src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
浏览文件 @
1e20b0a3
...
...
@@ -580,12 +580,12 @@ private async Task<XElement> TryDownloadFileAsync(IRemoteControlClient client)
DtdProcessing
=
DtdProcessing
.
Prohibit
,
XmlResolver
=
null
};
using
(
var
reader
=
XmlReader
.
Create
(
stream
,
settings
))
{
var
result
=
XElement
.
Load
(
reader
);
await
_service
.
LogInfoAsync
(
"Converting data to XElement completed"
).
ConfigureAwait
(
false
);
return
result
;
}
using
var
reader
=
XmlReader
.
Create
(
stream
,
settings
);
var
result
=
XElement
.
Load
(
reader
);
await
_service
.
LogInfoAsync
(
"Converting data to XElement completed"
).
ConfigureAwait
(
false
)
;
return
result
;
}
}
...
...
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
浏览文件 @
1e20b0a3
...
...
@@ -49,72 +49,71 @@ public bool ExecuteCommand(EncapsulateFieldCommandArgs args, CommandExecutionCon
private
bool
Execute
(
EncapsulateFieldCommandArgs
args
,
IUIThreadOperationScope
waitScope
)
{
using
(
var
token
=
_listener
.
BeginAsyncOperation
(
"EncapsulateField"
))
using
var
token
=
_listener
.
BeginAsyncOperation
(
"EncapsulateField"
);
var
cancellationToken
=
waitScope
.
Context
.
UserCancellationToken
;
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
waitScope
.
Context
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
==
null
)
{
var
cancellationToken
=
waitScope
.
Context
.
UserCancellationToken
;
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
waitScope
.
Context
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
==
null
)
{
return
false
;
}
return
false
;
}
var
spans
=
args
.
TextView
.
Selection
.
GetSnapshotSpansOnBuffer
(
args
.
SubjectBuffer
);
var
spans
=
args
.
TextView
.
Selection
.
GetSnapshotSpansOnBuffer
(
args
.
SubjectBuffer
);
var
service
=
document
.
GetLanguageService
<
AbstractEncapsulateFieldService
>();
var
service
=
document
.
GetLanguageService
<
AbstractEncapsulateFieldService
>();
var
result
=
service
.
EncapsulateFieldAsync
(
document
,
spans
.
First
().
Span
.
ToTextSpan
(),
true
,
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
result
=
service
.
EncapsulateFieldAsync
(
document
,
spans
.
First
().
Span
.
ToTextSpan
(),
true
,
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
// We are about to show a modal UI dialog so we should take over the command execution
// wait context. That means the command system won't attempt to show its own wait dialog
// and also will take it into consideration when measuring command handling duration.
waitScope
.
Context
.
TakeOwnership
();
// We are about to show a modal UI dialog so we should take over the command execution
// wait context. That means the command system won't attempt to show its own wait dialog
// and also will take it into consideration when measuring command handling duration.
waitScope
.
Context
.
TakeOwnership
();
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(
result
==
null
)
{
var
notificationService
=
workspace
.
Services
.
GetService
<
INotificationService
>();
notificationService
.
SendNotification
(
EditorFeaturesResources
.
Please_select_the_definition_of_the_field_to_encapsulate
,
severity
:
NotificationSeverity
.
Error
);
return
false
;
}
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(
result
==
null
)
{
var
notificationService
=
workspace
.
Services
.
GetService
<
INotificationService
>();
notificationService
.
SendNotification
(
EditorFeaturesResources
.
Please_select_the_definition_of_the_field_to_encapsulate
,
severity
:
NotificationSeverity
.
Error
);
return
false
;
}
waitScope
.
AllowCancellation
=
false
;
cancellationToken
=
waitScope
.
Context
.
UserCancellationToken
;
waitScope
.
AllowCancellation
=
false
;
cancellationToken
=
waitScope
.
Context
.
UserCancellationToken
;
var
finalSolution
=
result
.
GetSolutionAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
finalSolution
=
result
.
GetSolutionAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
previewService
=
workspace
.
Services
.
GetService
<
IPreviewDialogService
>();
if
(
previewService
!=
null
)
{
finalSolution
=
previewService
.
PreviewChanges
(
string
.
Format
(
EditorFeaturesResources
.
Preview_Changes_0
,
EditorFeaturesResources
.
Encapsulate_Field
),
"vs.csharp.refactoring.preview"
,
EditorFeaturesResources
.
Encapsulate_Field_colon
,
result
.
GetNameAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
),
result
.
GetGlyphAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
),
finalSolution
,
document
.
Project
.
Solution
);
}
var
previewService
=
workspace
.
Services
.
GetService
<
IPreviewDialogService
>();
if
(
previewService
!=
null
)
{
finalSolution
=
previewService
.
PreviewChanges
(
string
.
Format
(
EditorFeaturesResources
.
Preview_Changes_0
,
EditorFeaturesResources
.
Encapsulate_Field
),
"vs.csharp.refactoring.preview"
,
EditorFeaturesResources
.
Encapsulate_Field_colon
,
result
.
GetNameAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
),
result
.
GetGlyphAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
),
finalSolution
,
document
.
Project
.
Solution
);
}
if
(
finalSolution
==
null
)
{
// User clicked cancel.
return
true
;
}
if
(
finalSolution
==
null
)
{
// User clicked cancel.
return
true
;
}
using
(
var
undoTransaction
=
_undoManager
.
GetTextBufferUndoManager
(
args
.
SubjectBuffer
).
TextBufferUndoHistory
.
CreateTransaction
(
EditorFeaturesResources
.
Encapsulate_Field
))
using
(
var
undoTransaction
=
_undoManager
.
GetTextBufferUndoManager
(
args
.
SubjectBuffer
).
TextBufferUndoHistory
.
CreateTransaction
(
EditorFeaturesResources
.
Encapsulate_Field
))
{
if
(!
workspace
.
TryApplyChanges
(
finalSolution
))
{
if
(!
workspace
.
TryApplyChanges
(
finalSolution
))
{
undoTransaction
.
Cancel
();
return
false
;
}
undoTransaction
.
Complete
();
undoTransaction
.
Cancel
();
return
false
;
}
return
true
;
undoTransaction
.
Complete
()
;
}
return
true
;
}
public
VSCommanding
.
CommandState
GetCommandState
(
EncapsulateFieldCommandArgs
args
)
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
浏览文件 @
1e20b0a3
...
...
@@ -304,31 +304,30 @@ private ImmutableArray<string> GetFolderNamesForFolder(uint folderItemID)
{
AssertIsForeground
();
using
(
var
pooledObject
=
SharedPools
.
Default
<
List
<
string
>>().
GetPooledObject
())
{
var
newFolderNames
=
pooledObject
.
Object
;
using
var
pooledObject
=
SharedPools
.
Default
<
List
<
string
>>().
GetPooledObject
();
var
newFolderNames
=
pooledObject
.
Object
;
if
(!
_folderNameMap
.
TryGetValue
(
folderItemID
,
out
var
folderNames
))
if
(!
_folderNameMap
.
TryGetValue
(
folderItemID
,
out
var
folderNames
))
{
ComputeFolderNames
(
folderItemID
,
newFolderNames
,
Hierarchy
);
folderNames
=
newFolderNames
.
ToImmutableArray
();
_folderNameMap
.
Add
(
folderItemID
,
folderNames
);
}
else
{
// verify names, and change map if we get a different set.
// this is necessary because we only get document adds/removes from the project system
// when a document name or folder name changes.
ComputeFolderNames
(
folderItemID
,
newFolderNames
,
Hierarchy
);
if
(!
Enumerable
.
SequenceEqual
(
folderNames
,
newFolderNames
))
{
ComputeFolderNames
(
folderItemID
,
newFolderNames
,
Hierarchy
);
folderNames
=
newFolderNames
.
ToImmutableArray
();
_folderNameMap
.
Add
(
folderItemID
,
folderNames
);
}
else
{
// verify names, and change map if we get a different set.
// this is necessary because we only get document adds/removes from the project system
// when a document name or folder name changes.
ComputeFolderNames
(
folderItemID
,
newFolderNames
,
Hierarchy
);
if
(!
Enumerable
.
SequenceEqual
(
folderNames
,
newFolderNames
))
{
folderNames
=
newFolderNames
.
ToImmutableArray
();
_folderNameMap
[
folderItemID
]
=
folderNames
;
}
_folderNameMap
[
folderItemID
]
=
folderNames
;
}
return
folderNames
;
}
return
folderNames
;
}
// Different hierarchies are inconsistent on whether they return ints or uints for VSItemIds.
...
...
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
浏览文件 @
1e20b0a3
...
...
@@ -328,19 +328,18 @@ private bool WhitespaceOnEdges(SourceText text, TextSpan visibleTextSpan, TextCh
private
IEnumerable
<
TextChange
>
GetSubTextChanges
(
SourceText
originalText
,
TextChange
changeInOriginalText
,
TextSpan
visibleSpanInOriginalText
)
{
using
(
var
changes
=
SharedPools
.
Default
<
List
<
TextChange
>>().
GetPooledObject
())
{
var
leftText
=
originalText
.
ToString
(
changeInOriginalText
.
Span
);
var
rightText
=
changeInOriginalText
.
NewText
;
var
offsetInOriginalText
=
changeInOriginalText
.
Span
.
Start
;
using
var
changes
=
SharedPools
.
Default
<
List
<
TextChange
>>().
GetPooledObject
();
if
(
TryGetSubTextChanges
(
originalText
,
visibleSpanInOriginalText
,
leftText
,
rightText
,
offsetInOriginalText
,
changes
.
Object
))
{
return
changes
.
Object
.
ToList
();
}
var
leftText
=
originalText
.
ToString
(
changeInOriginalText
.
Span
);
var
rightText
=
changeInOriginalText
.
NewText
;
var
offsetInOriginalText
=
changeInOriginalText
.
Span
.
Start
;
return
GetSubTextChanges
(
originalText
,
visibleSpanInOriginalText
,
leftText
,
rightText
,
offsetInOriginalText
);
if
(
TryGetSubTextChanges
(
originalText
,
visibleSpanInOriginalText
,
leftText
,
rightText
,
offsetInOriginalText
,
changes
.
Object
))
{
return
changes
.
Object
.
ToList
();
}
return
GetSubTextChanges
(
originalText
,
visibleSpanInOriginalText
,
leftText
,
rightText
,
offsetInOriginalText
);
}
private
bool
TryGetSubTextChanges
(
...
...
@@ -766,24 +765,22 @@ private void AdjustIndentation(IProjectionBuffer subjectBuffer, IEnumerable<int>
.
WithChangedOption
(
FormattingOptions
.
TabSize
,
root
.
Language
,
editorOptions
.
GetTabSize
())
.
WithChangedOption
(
FormattingOptions
.
IndentationSize
,
root
.
Language
,
editorOptions
.
GetIndentSize
());
using
(
var
pooledObject
=
SharedPools
.
Default
<
List
<
TextSpan
>>().
GetPooledObject
())
{
var
spans
=
pooledObject
.
Object
;
using
var
pooledObject
=
SharedPools
.
Default
<
List
<
TextSpan
>>().
GetPooledObject
();
spans
.
AddRange
(
this
.
GetEditorVisibleSpans
());
using
(
var
edit
=
subjectBuffer
.
CreateEdit
(
s_venusEditOptions
,
reiteratedVersionNumber
:
null
,
editTag
:
null
))
{
foreach
(
var
spanIndex
in
visibleSpanIndex
)
{
var
rule
=
GetBaseIndentationRule
(
root
,
originalText
,
spans
,
spanIndex
);
var
spans
=
pooledObject
.
Object
;
var
visibleSpan
=
spans
[
spanIndex
];
AdjustIndentationForSpan
(
document
,
edit
,
visibleSpan
,
rule
,
options
);
}
spans
.
AddRange
(
this
.
GetEditorVisibleSpans
());
using
var
edit
=
subjectBuffer
.
CreateEdit
(
s_venusEditOptions
,
reiteratedVersionNumber
:
null
,
editTag
:
null
);
edit
.
Apply
();
}
foreach
(
var
spanIndex
in
visibleSpanIndex
)
{
var
rule
=
GetBaseIndentationRule
(
root
,
originalText
,
spans
,
spanIndex
);
var
visibleSpan
=
spans
[
spanIndex
];
AdjustIndentationForSpan
(
document
,
edit
,
visibleSpan
,
rule
,
options
);
}
edit
.
Apply
();
}
private
void
AdjustIndentationForSpan
(
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpNavigateTo.cs
浏览文件 @
1e20b0a3
...
...
@@ -25,34 +25,32 @@ public CSharpNavigateTo(VisualStudioInstanceFactory instanceFactory, ITestOutput
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
NavigateTo
)]
public
void
NavigateTo
()
{
using
(
var
telemetry
=
VisualStudio
.
EnableTestTelemetryChannel
())
{
using
var
telemetry
=
VisualStudio
.
EnableTestTelemetryChannel
();
var
project
=
new
ProjectUtils
.
Project
(
ProjectName
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"test1.cs"
,
open
:
false
,
contents
:
@"
var
project
=
new
ProjectUtils
.
Project
(
ProjectName
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"test1.cs"
,
open
:
false
,
contents
:
@"
class FirstClass
{
void FirstMethod() { }
}"
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"test2.cs"
,
open
:
true
,
contents
:
@"
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"test2.cs"
,
open
:
true
,
contents
:
@"
"
);
VisualStudio
.
Editor
.
InvokeNavigateTo
(
"FirstMethod"
,
VirtualKey
.
Enter
);
VisualStudio
.
Editor
.
WaitForActiveView
(
"test1.cs"
);
Assert
.
Equal
(
"FirstMethod"
,
VisualStudio
.
Editor
.
GetSelectedText
());
VisualStudio
.
Editor
.
InvokeNavigateTo
(
"FirstMethod"
,
VirtualKey
.
Enter
);
VisualStudio
.
Editor
.
WaitForActiveView
(
"test1.cs"
);
Assert
.
Equal
(
"FirstMethod"
,
VisualStudio
.
Editor
.
GetSelectedText
());
// Add a VB project and verify that VB files are found when searching from C#
var
vbProject
=
new
ProjectUtils
.
Project
(
"VBProject"
);
VisualStudio
.
SolutionExplorer
.
AddProject
(
vbProject
,
WellKnownProjectTemplates
.
ClassLibrary
,
LanguageNames
.
VisualBasic
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
vbProject
,
"vbfile.vb"
,
open
:
true
);
// Add a VB project and verify that VB files are found when searching from C#
var
vbProject
=
new
ProjectUtils
.
Project
(
"VBProject"
);
VisualStudio
.
SolutionExplorer
.
AddProject
(
vbProject
,
WellKnownProjectTemplates
.
ClassLibrary
,
LanguageNames
.
VisualBasic
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
vbProject
,
"vbfile.vb"
,
open
:
true
);
VisualStudio
.
Editor
.
InvokeNavigateTo
(
"FirstClass"
,
VirtualKey
.
Enter
);
VisualStudio
.
Editor
.
WaitForActiveView
(
"test1.cs"
);
Assert
.
Equal
(
"FirstClass"
,
VisualStudio
.
Editor
.
GetSelectedText
());
telemetry
.
VerifyFired
(
"vs/ide/vbcs/navigateto/search"
,
"vs/platform/goto/launch"
);
}
VisualStudio
.
Editor
.
InvokeNavigateTo
(
"FirstClass"
,
VirtualKey
.
Enter
);
VisualStudio
.
Editor
.
WaitForActiveView
(
"test1.cs"
);
Assert
.
Equal
(
"FirstClass"
,
VisualStudio
.
Editor
.
GetSelectedText
());
telemetry
.
VerifyFired
(
"vs/ide/vbcs/navigateto/search"
,
"vs/platform/goto/launch"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录