Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
94ee71e0
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,发现更多精彩内容 >>
提交
94ee71e0
编写于
6月 28, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use simple usings
上级
4226d8ce
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
210 addition
and
231 deletion
+210
-231
src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
...tomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
+9
-10
src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.cs
....Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.cs
+3
-4
src/EditorFeatures/Core/Implementation/AutomaticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
...ticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
+11
-12
src/EditorFeatures/Core/Implementation/BlockCommentEditing/BaseAbstractBlockCommentEditingCommandHandler.cs
...tEditing/BaseAbstractBlockCommentEditingCommandHandler.cs
+7
-8
src/EditorFeatures/Core/Implementation/DocumentationComments/AbstractXmlTagCompletionCommandHandler.cs
...ntationComments/AbstractXmlTagCompletionCommandHandler.cs
+8
-9
src/EditorFeatures/Core/Implementation/EditAndContinue/ReadOnlyDocumentTracker.cs
...Implementation/EditAndContinue/ReadOnlyDocumentTracker.cs
+4
-5
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
...ncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
+3
-4
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
...tion/ExtractMethod/AbstractExtractMethodCommandHandler.cs
+7
-8
src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTaggerProvider.RenameTrackingCommitter.cs
...g/RenameTrackingTaggerProvider.RenameTrackingCommitter.cs
+22
-23
src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentState.cs
...tures/Core/Implementation/TodoComment/TodoCommentState.cs
+17
-18
src/VisualStudio/CSharp/Impl/CodeModel/MethodXml/MethodXmlBuilder.cs
...tudio/CSharp/Impl/CodeModel/MethodXml/MethodXmlBuilder.cs
+5
-6
src/VisualStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
...alStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
+11
-12
src/VisualStudio/CSharp/Test/Debugging/NameResolverTests.cs
src/VisualStudio/CSharp/Test/Debugging/NameResolverTests.cs
+5
-6
src/VisualStudio/CSharp/Test/EventHookup/EventHookupCommandHandlerTests.cs
...CSharp/Test/EventHookup/EventHookupCommandHandlerTests.cs
+11
-12
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
...Studio/Core/Def/Implementation/Venus/ContainedDocument.cs
+40
-41
src/VisualStudio/Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
...Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
+3
-4
src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs
...bols/Declarations/DeclarationFinder_SourceDeclarations.cs
+22
-25
src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs
...e/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs
+5
-6
src/Workspaces/Remote/ServiceHub/Services/SnapshotService.JsonRpcAssetSource.cs
...ServiceHub/Services/SnapshotService.JsonRpcAssetSource.cs
+17
-18
未找到文件。
src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
浏览文件 @
94ee71e0
...
...
@@ -60,19 +60,18 @@ public override void AfterReturn(IBraceCompletionSession session, CancellationTo
// alright, it is in right shape.
var
undoHistory
=
GetUndoHistory
(
session
.
TextView
);
using
(
var
transaction
=
undoHistory
.
CreateTransaction
(
EditorFeaturesResources
.
Brace_Completion
))
using
var
transaction
=
undoHistory
.
CreateTransaction
(
EditorFeaturesResources
.
Brace_Completion
);
var
document
=
session
.
SubjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
if
(
document
!=
null
)
{
var
document
=
session
.
SubjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
if
(
document
!=
null
)
{
document
.
InsertText
(
session
.
ClosingPoint
.
GetPosition
(
session
.
SubjectBuffer
.
CurrentSnapshot
)
-
1
,
Environment
.
NewLine
,
cancellationToken
);
FormatTrackingSpan
(
session
,
shouldHonorAutoFormattingOnCloseBraceOption
:
false
,
rules
:
GetFormattingRules
(
document
));
document
.
InsertText
(
session
.
ClosingPoint
.
GetPosition
(
session
.
SubjectBuffer
.
CurrentSnapshot
)
-
1
,
Environment
.
NewLine
,
cancellationToken
);
FormatTrackingSpan
(
session
,
shouldHonorAutoFormattingOnCloseBraceOption
:
false
,
rules
:
GetFormattingRules
(
document
));
// put caret at right indentation
PutCaretOnLine
(
session
,
session
.
OpeningPoint
.
GetPoint
(
session
.
SubjectBuffer
.
CurrentSnapshot
).
GetContainingLineNumber
()
+
1
);
// put caret at right indentation
PutCaretOnLine
(
session
,
session
.
OpeningPoint
.
GetPoint
(
session
.
SubjectBuffer
.
CurrentSnapshot
).
GetContainingLineNumber
()
+
1
);
transaction
.
Complete
();
}
transaction
.
Complete
();
}
}
...
...
src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.cs
浏览文件 @
94ee71e0
...
...
@@ -179,10 +179,9 @@ public async Task<IDocumentOptions> GetOptionsForDocumentAsync(Document document
// as in some builds the ICodingConventionsManager captures the thread pool.
var
conventionsAsync
=
Task
.
Run
(()
=>
GetConventionContextAsync
(
path
,
cancellationToken
));
using
(
var
context
=
await
conventionsAsync
.
ConfigureAwait
(
false
))
{
return
new
DocumentOptions
(
context
.
CurrentConventions
,
_errorLogger
);
}
using
var
context
=
await
conventionsAsync
.
ConfigureAwait
(
false
);
return
new
DocumentOptions
(
context
.
CurrentConventions
,
_errorLogger
);
}
}
...
...
src/EditorFeatures/Core/Implementation/AutomaticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
浏览文件 @
94ee71e0
...
...
@@ -111,22 +111,21 @@ public void ExecuteCommand(AutomaticLineEnderCommandArgs args, Action nextHandle
return
;
}
using
(
var
transaction
=
args
.
TextView
.
CreateEditTransaction
(
EditorFeaturesResources
.
Automatic_Line_Ender
,
_undoRegistry
,
_editorOperationsFactoryService
))
{
// try to move the caret to the end of the line on which the caret is
args
.
TextView
.
TryMoveCaretToAndEnsureVisible
(
subjectLineWhereCaretIsOn
.
End
);
using
var
transaction
=
args
.
TextView
.
CreateEditTransaction
(
EditorFeaturesResources
.
Automatic_Line_Ender
,
_undoRegistry
,
_editorOperationsFactoryService
);
// okay, now insert ending if we need to
var
newDocument
=
InsertEndingIfRequired
(
document
,
insertionPoint
.
Value
,
position
.
Value
,
userCancellationToken
);
// try to move the caret to the end of the line on which the caret is
args
.
TextView
.
TryMoveCaretToAndEnsureVisible
(
subjectLineWhereCaretIsOn
.
End
);
// format the document and apply the changes to the workspace
FormatAndApply
(
newDocument
,
insertionPoint
.
Value
,
userCancellationToken
);
// okay, now insert ending if we need to
var
newDocument
=
InsertEndingIfRequired
(
document
,
insertionPoint
.
Value
,
position
.
Value
,
userCancellationToken
);
// now, insert new lin
e
NextAction
(
operations
,
nextHandler
);
// format the document and apply the changes to the workspac
e
FormatAndApply
(
newDocument
,
insertionPoint
.
Value
,
userCancellationToken
);
transaction
.
Complete
();
}
// now, insert new line
NextAction
(
operations
,
nextHandler
);
transaction
.
Complete
();
}
}
...
...
src/EditorFeatures/Core/Implementation/BlockCommentEditing/BaseAbstractBlockCommentEditingCommandHandler.cs
浏览文件 @
94ee71e0
...
...
@@ -47,16 +47,15 @@ protected bool TryHandleReturnKey(ITextBuffer subjectBuffer, ITextView textView)
return
false
;
}
using
(
var
transaction
=
_undoHistoryRegistry
.
GetHistory
(
textView
.
TextBuffer
).
CreateTransaction
(
EditorFeaturesResources
.
Insert_new_line
))
{
var
editorOperations
=
_editorOperationsFactoryService
.
GetEditorOperations
(
textView
);
using
var
transaction
=
_undoHistoryRegistry
.
GetHistory
(
textView
.
TextBuffer
).
CreateTransaction
(
EditorFeaturesResources
.
Insert_new_line
);
editorOperations
.
InsertNewLine
();
editorOperations
.
InsertText
(
exteriorText
);
var
editorOperations
=
_editorOperationsFactoryService
.
GetEditorOperations
(
textView
);
transaction
.
Complete
();
return
true
;
}
editorOperations
.
InsertNewLine
();
editorOperations
.
InsertText
(
exteriorText
);
transaction
.
Complete
();
return
true
;
}
protected
abstract
string
GetExteriorTextForNextLine
(
SnapshotPoint
caretPosition
);
...
...
src/EditorFeatures/Core/Implementation/DocumentationComments/AbstractXmlTagCompletionCommandHandler.cs
浏览文件 @
94ee71e0
...
...
@@ -67,18 +67,17 @@ public void ExecuteCommand(TypeCharCommandArgs args, Action nextHandler, Command
protected
void
InsertTextAndMoveCaret
(
ITextView
textView
,
ITextBuffer
subjectBuffer
,
SnapshotPoint
position
,
string
insertionText
,
int
?
finalCaretPosition
)
{
using
(
var
transaction
=
_undoHistory
.
GetHistory
(
textView
.
TextBuffer
).
CreateTransaction
(
"XmlTagCompletion"
))
{
subjectBuffer
.
Insert
(
position
,
insertionText
);
using
var
transaction
=
_undoHistory
.
GetHistory
(
textView
.
TextBuffer
).
CreateTransaction
(
"XmlTagCompletion"
);
if
(
finalCaretPosition
.
HasValue
)
{
var
point
=
subjectBuffer
.
CurrentSnapshot
.
GetPoint
(
finalCaretPosition
.
Value
);
textView
.
TryMoveCaretToAndEnsureVisible
(
point
);
}
subjectBuffer
.
Insert
(
position
,
insertionText
);
transaction
.
Complete
();
if
(
finalCaretPosition
.
HasValue
)
{
var
point
=
subjectBuffer
.
CurrentSnapshot
.
GetPoint
(
finalCaretPosition
.
Value
);
textView
.
TryMoveCaretToAndEnsureVisible
(
point
);
}
transaction
.
Complete
();
}
}
}
src/EditorFeatures/Core/Implementation/EditAndContinue/ReadOnlyDocumentTracker.cs
浏览文件 @
94ee71e0
...
...
@@ -112,11 +112,10 @@ private void RemoveReadOnlyRegionFromBuffer(DocumentId documentId, IReadOnlyRegi
AssertIsForeground
();
var
textBuffer
=
GetTextBuffer
(
_workspace
,
documentId
);
using
(
var
readOnlyEdit
=
textBuffer
.
CreateReadOnlyRegionEdit
())
{
readOnlyEdit
.
RemoveReadOnlyRegion
(
region
);
readOnlyEdit
.
Apply
();
}
using
var
readOnlyEdit
=
textBuffer
.
CreateReadOnlyRegionEdit
();
readOnlyEdit
.
RemoveReadOnlyRegion
(
region
);
readOnlyEdit
.
Apply
();
}
private
static
ITextBuffer
GetTextBuffer
(
Workspace
workspace
,
DocumentId
documentId
)
...
...
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
浏览文件 @
94ee71e0
...
...
@@ -42,10 +42,9 @@ public bool ExecuteCommand(EncapsulateFieldCommandArgs args, CommandExecutionCon
return
false
;
}
using
(
var
waitScope
=
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Applying_Encapsulate_Field_refactoring
))
{
return
Execute
(
args
,
waitScope
);
}
using
var
waitScope
=
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Applying_Encapsulate_Field_refactoring
);
return
Execute
(
args
,
waitScope
);
}
private
bool
Execute
(
EncapsulateFieldCommandArgs
args
,
IUIThreadOperationScope
waitScope
)
...
...
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
浏览文件 @
94ee71e0
...
...
@@ -238,15 +238,14 @@ private bool TryNotifyFailureToUser(Document document, ExtractMethodResult resul
/// </summary>
private
void
ApplyChangesToBuffer
(
ExtractMethodResult
extractMethodResult
,
ITextBuffer
subjectBuffer
,
CancellationToken
cancellationToken
)
{
using
(
var
undoTransaction
=
_undoManager
.
GetTextBufferUndoManager
(
subjectBuffer
).
TextBufferUndoHistory
.
CreateTransaction
(
"Extract Method"
))
{
// apply extract method code to buffer
var
document
=
extractMethodResult
.
Document
;
document
.
Project
.
Solution
.
Workspace
.
ApplyDocumentChanges
(
document
,
cancellationToken
);
using
var
undoTransaction
=
_undoManager
.
GetTextBufferUndoManager
(
subjectBuffer
).
TextBufferUndoHistory
.
CreateTransaction
(
"Extract Method"
);
// apply changes
undoTransaction
.
Complete
();
}
// apply extract method code to buffer
var
document
=
extractMethodResult
.
Document
;
document
.
Project
.
Solution
.
Workspace
.
ApplyDocumentChanges
(
document
,
cancellationToken
);
// apply changes
undoTransaction
.
Complete
();
}
}
}
src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTaggerProvider.RenameTrackingCommitter.cs
浏览文件 @
94ee71e0
...
...
@@ -262,33 +262,32 @@ private void UpdateWorkspaceForResetOfTypedIdentifier(Workspace workspace, Solut
var
undoHistory
=
_undoHistoryRegistry
.
RegisterHistory
(
_stateMachine
.
Buffer
);
using
(
var
workspaceUndoTransaction
=
workspace
.
OpenGlobalUndoTransaction
(
undoName
))
using
(
var
localUndoTransaction
=
undoHistory
.
CreateTransaction
(
undoName
))
{
var
undoPrimitiveBefore
=
new
UndoPrimitive
(
_stateMachine
.
Buffer
,
trackingSessionId
,
shouldRestoreStateOnUndo
:
false
);
localUndoTransaction
.
AddUndo
(
undoPrimitiveBefore
);
using
var
workspaceUndoTransaction
=
workspace
.
OpenGlobalUndoTransaction
(
undoName
);
using
var
localUndoTransaction
=
undoHistory
.
CreateTransaction
(
undoName
);
if
(!
workspace
.
TryApplyChanges
(
newSolution
))
{
Contract
.
Fail
(
"Rename Tracking could not update solution."
);
}
var
undoPrimitiveBefore
=
new
UndoPrimitive
(
_stateMachine
.
Buffer
,
trackingSessionId
,
shouldRestoreStateOnUndo
:
false
);
localUndoTransaction
.
AddUndo
(
undoPrimitiveBefore
);
if
(!
_refactorNotifyServices
.
TryOnAfterGlobalSymbolRenamed
(
workspace
,
changedDocuments
,
symbol
,
newName
,
throwOnFailure
:
false
))
{
var
notificationService
=
workspace
.
Services
.
GetService
<
INotificationService
>();
notificationService
.
SendNotification
(
EditorFeaturesResources
.
Rename_operation_was_not_properly_completed_Some_file_might_not_have_been_updated
,
EditorFeaturesResources
.
Rename_Symbol
,
NotificationSeverity
.
Information
);
}
// Never resume tracking session on redo
var
undoPrimitiveAfter
=
new
UndoPrimitive
(
_stateMachine
.
Buffer
,
trackingSessionId
,
shouldRestoreStateOnUndo
:
false
);
localUndoTransaction
.
AddUndo
(
undoPrimitiveAfter
);
if
(!
workspace
.
TryApplyChanges
(
newSolution
))
{
Contract
.
Fail
(
"Rename Tracking could not update solution."
);
}
localUndoTransaction
.
Complete
();
workspaceUndoTransaction
.
Commit
();
if
(!
_refactorNotifyServices
.
TryOnAfterGlobalSymbolRenamed
(
workspace
,
changedDocuments
,
symbol
,
newName
,
throwOnFailure
:
false
))
{
var
notificationService
=
workspace
.
Services
.
GetService
<
INotificationService
>();
notificationService
.
SendNotification
(
EditorFeaturesResources
.
Rename_operation_was_not_properly_completed_Some_file_might_not_have_been_updated
,
EditorFeaturesResources
.
Rename_Symbol
,
NotificationSeverity
.
Information
);
}
// Never resume tracking session on redo
var
undoPrimitiveAfter
=
new
UndoPrimitive
(
_stateMachine
.
Buffer
,
trackingSessionId
,
shouldRestoreStateOnUndo
:
false
);
localUndoTransaction
.
AddUndo
(
undoPrimitiveAfter
);
localUndoTransaction
.
Complete
();
workspaceUndoTransaction
.
Commit
();
}
}
}
...
...
src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentState.cs
浏览文件 @
94ee71e0
...
...
@@ -48,29 +48,28 @@ protected override Data TryGetExistingData(Stream stream, Document value, Cancel
protected
override
void
WriteTo
(
Stream
stream
,
Data
data
,
CancellationToken
cancellationToken
)
{
using
(
var
writer
=
new
ObjectWriter
(
stream
,
cancellationToken
:
cancellationToken
))
{
writer
.
WriteString
(
FormatVersion
);
data
.
TextVersion
.
WriteTo
(
writer
);
data
.
SyntaxVersion
.
WriteTo
(
writer
);
using
var
writer
=
new
ObjectWriter
(
stream
,
cancellationToken
:
cancellationToken
);
writer
.
WriteInt32
(
data
.
Items
.
Length
);
writer
.
WriteString
(
FormatVersion
);
data
.
TextVersion
.
WriteTo
(
writer
);
data
.
SyntaxVersion
.
WriteTo
(
writer
);
foreach
(
var
item
in
data
.
Items
.
OfType
<
TodoItem
>())
{
cancellationToken
.
ThrowIfCancellationRequested
();
writer
.
WriteInt32
(
data
.
Items
.
Length
);
foreach
(
var
item
in
data
.
Items
.
OfType
<
TodoItem
>())
{
cancellationToken
.
ThrowIfCancellationRequested
();
writer
.
WriteInt32
(
item
.
Priority
);
writer
.
WriteString
(
item
.
Message
);
writer
.
WriteInt32
(
item
.
Priority
);
writer
.
WriteString
(
item
.
Message
);
writer
.
WriteString
(
item
.
OriginalFilePath
);
writer
.
WriteInt32
(
item
.
OriginalLine
);
writer
.
WriteInt32
(
item
.
OriginalColumn
);
writer
.
WriteString
(
item
.
OriginalFilePath
);
writer
.
WriteInt32
(
item
.
OriginalLine
);
writer
.
WriteInt32
(
item
.
OriginalColumn
);
writer
.
WriteString
(
item
.
MappedFilePath
);
writer
.
WriteInt32
(
item
.
MappedLine
);
writer
.
WriteInt32
(
item
.
MappedColumn
);
}
writer
.
WriteString
(
item
.
MappedFilePath
);
writer
.
WriteInt32
(
item
.
MappedLine
);
writer
.
WriteInt32
(
item
.
MappedColumn
);
}
}
...
...
src/VisualStudio/CSharp/Impl/CodeModel/MethodXml/MethodXmlBuilder.cs
浏览文件 @
94ee71e0
...
...
@@ -42,12 +42,11 @@ private void GenerateComments(SyntaxTriviaList triviaList)
var
firstNonWhitespacePosition
=
line
.
GetFirstNonWhitespacePosition
()
??
-
1
;
if
(
firstNonWhitespacePosition
==
trivia
.
SpanStart
)
{
using
(
var
tag
=
CommentTag
())
{
// Skip initial slashes
var
trimmedComment
=
trivia
.
ToString
().
Substring
(
2
);
EncodedText
(
trimmedComment
);
}
using
var
tag
=
CommentTag
();
// Skip initial slashes
var
trimmedComment
=
trivia
.
ToString
().
Substring
(
2
);
EncodedText
(
trimmedComment
);
}
}
}
...
...
src/VisualStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
浏览文件 @
94ee71e0
...
...
@@ -17,18 +17,17 @@ public class LocationInfoGetterTests
{
private
async
Task
TestAsync
(
string
markup
,
string
expectedName
,
int
expectedLineOffset
,
CSharpParseOptions
parseOptions
=
null
)
{
using
(
var
workspace
=
TestWorkspace
.
CreateCSharp
(
markup
,
parseOptions
))
{
var
testDocument
=
workspace
.
Documents
.
Single
();
var
position
=
testDocument
.
CursorPosition
.
Value
;
var
locationInfo
=
await
LocationInfoGetter
.
GetInfoAsync
(
workspace
.
CurrentSolution
.
Projects
.
Single
().
Documents
.
Single
(),
position
,
CancellationToken
.
None
);
Assert
.
Equal
(
expectedName
,
locationInfo
.
Name
);
Assert
.
Equal
(
expectedLineOffset
,
locationInfo
.
LineOffset
);
}
using
var
workspace
=
TestWorkspace
.
CreateCSharp
(
markup
,
parseOptions
);
var
testDocument
=
workspace
.
Documents
.
Single
();
var
position
=
testDocument
.
CursorPosition
.
Value
;
var
locationInfo
=
await
LocationInfoGetter
.
GetInfoAsync
(
workspace
.
CurrentSolution
.
Projects
.
Single
().
Documents
.
Single
(),
position
,
CancellationToken
.
None
);
Assert
.
Equal
(
expectedName
,
locationInfo
.
Name
);
Assert
.
Equal
(
expectedLineOffset
,
locationInfo
.
LineOffset
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)]
...
...
src/VisualStudio/CSharp/Test/Debugging/NameResolverTests.cs
浏览文件 @
94ee71e0
...
...
@@ -27,12 +27,11 @@ private async Task TestAsync(string text, string searchText, params string[] exp
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingNameResolver
)]
public
async
Task
TestCSharpLanguageDebugInfoCreateNameResolver
()
{
using
(
var
workspace
=
TestWorkspace
.
CreateCSharp
(
" "
))
{
var
debugInfo
=
new
CSharpBreakpointResolutionService
();
var
results
=
await
debugInfo
.
ResolveBreakpointsAsync
(
workspace
.
CurrentSolution
,
"goo"
,
CancellationToken
.
None
);
Assert
.
Equal
(
0
,
results
.
Count
());
}
using
var
workspace
=
TestWorkspace
.
CreateCSharp
(
" "
);
var
debugInfo
=
new
CSharpBreakpointResolutionService
();
var
results
=
await
debugInfo
.
ResolveBreakpointsAsync
(
workspace
.
CurrentSolution
,
"goo"
,
CancellationToken
.
None
);
Assert
.
Equal
(
0
,
results
.
Count
());
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingNameResolver
)]
...
...
src/VisualStudio/CSharp/Test/EventHookup/EventHookupCommandHandlerTests.cs
浏览文件 @
94ee71e0
...
...
@@ -337,20 +337,19 @@ void M()
MyEvent +$$
}
}"
;
using
(
var
testState
=
EventHookupTestState
.
CreateTestState
(
markup
))
{
testState
.
SendTypeChar
(
'='
);
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertShowing
(
"C_MyEvent;"
);
using
var
testState
=
EventHookupTestState
.
CreateTestState
(
markup
);
testState
.
SendTypeChar
(
'
'
);
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertShowing
(
"C_MyEvent;"
);
testState
.
SendTypeChar
(
'=
'
);
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertShowing
(
"C_MyEvent;"
);
testState
.
SendBackspace
();
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertNotShowing
();
}
testState
.
SendTypeChar
(
' '
);
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertShowing
(
"C_MyEvent;"
);
testState
.
SendBackspace
();
await
testState
.
WaitForAsynchronousOperationsAsync
();
testState
.
AssertNotShowing
();
}
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
EventHookup
)]
...
...
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
浏览文件 @
94ee71e0
...
...
@@ -248,60 +248,59 @@ private IEnumerable<TextChange> FilterTextChanges(SourceText originalText, List<
yield
break
;
}
using
(
var
pooledObject
=
SharedPools
.
Default
<
List
<
TextChange
>>().
GetPooledObject
())
using
var
pooledObject
=
SharedPools
.
Default
<
List
<
TextChange
>>().
GetPooledObject
();
var
changeQueue
=
pooledObject
.
Object
;
changeQueue
.
AddRange
(
changes
);
var
spanIndex
=
0
;
var
changeIndex
=
0
;
for
(;
spanIndex
<
editorVisibleSpansInOriginal
.
Count
;
spanIndex
++)
{
var
changeQueue
=
pooledObject
.
Object
;
changeQueue
.
AddRange
(
changes
);
var
visibleSpan
=
editorVisibleSpansInOriginal
[
spanIndex
]
;
var
visibleTextSpan
=
GetVisibleTextSpan
(
originalText
,
visibleSpan
,
uptoFirstAndLastLine
:
true
);
var
spanIndex
=
0
;
var
changeIndex
=
0
;
for
(;
spanIndex
<
editorVisibleSpansInOriginal
.
Count
;
spanIndex
++)
for
(;
changeIndex
<
changeQueue
.
Count
;
changeIndex
++)
{
var
visibleSpan
=
editorVisibleSpansInOriginal
[
spanIndex
];
var
visibleTextSpan
=
GetVisibleTextSpan
(
originalText
,
visibleSpan
,
uptoFirstAndLastLine
:
true
);
var
change
=
changeQueue
[
changeIndex
];
for
(;
changeIndex
<
changeQueue
.
Count
;
changeIndex
++)
// easy case first
if
(
change
.
Span
.
End
<
visibleSpan
.
Start
)
{
var
change
=
changeQueue
[
changeIndex
];
// move to next change
continue
;
}
// easy case first
if
(
change
.
Span
.
End
<
visibleSpan
.
Start
)
{
// move to next change
continue
;
}
if
(
visibleSpan
.
End
<
change
.
Span
.
Start
)
{
// move to next visible span
break
;
}
if
(
visibleSpan
.
End
<
change
.
Span
.
Start
)
{
// move to next visible span
break
;
}
// make sure we are not replacing whitespace around start and at the end of visible span
if
(
WhitespaceOnEdges
(
originalText
,
visibleTextSpan
,
change
))
{
continue
;
}
// make sure we are not replacing whitespace around start and at the end of visible span
if
(
WhitespaceOnEdges
(
originalText
,
visibleTextSpan
,
change
))
{
continue
;
}
if
(
visibleSpan
.
Contains
(
change
.
Span
))
{
yield
return
change
;
continue
;
}
if
(
visibleSpan
.
Contains
(
change
.
Span
))
// now it is complex case where things are intersecting each other
var
subChanges
=
GetSubTextChanges
(
originalText
,
change
,
visibleSpan
).
ToList
();
if
(
subChanges
.
Count
>
0
)
{
if
(
subChanges
.
Count
==
1
&&
subChanges
[
0
]
==
change
)
{
yield
return
change
;
// we can't break it. not much we can do here. just don't touch and ignore this change
continue
;
}
// now it is complex case where things are intersecting each other
var
subChanges
=
GetSubTextChanges
(
originalText
,
change
,
visibleSpan
).
ToList
();
if
(
subChanges
.
Count
>
0
)
{
if
(
subChanges
.
Count
==
1
&&
subChanges
[
0
]
==
change
)
{
// we can't break it. not much we can do here. just don't touch and ignore this change
continue
;
}
changeQueue
.
InsertRange
(
changeIndex
+
1
,
subChanges
);
continue
;
}
changeQueue
.
InsertRange
(
changeIndex
+
1
,
subChanges
);
continue
;
}
}
}
...
...
src/VisualStudio/Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
浏览文件 @
94ee71e0
...
...
@@ -465,10 +465,9 @@ protected void GenerateType(ITypeSymbol type, bool? @implicit = null, bool assem
if
(
type
.
TypeKind
==
TypeKind
.
Array
)
{
var
arrayType
=
(
IArrayTypeSymbol
)
type
;
using
(
var
tag
=
ArrayTypeTag
(
arrayType
.
Rank
))
{
GenerateType
(
arrayType
.
ElementType
,
@implicit
,
assemblyQualify
);
}
using
var
tag
=
ArrayTypeTag
(
arrayType
.
Rank
);
GenerateType
(
arrayType
.
ElementType
,
@implicit
,
assemblyQualify
);
}
else
{
...
...
src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs
浏览文件 @
94ee71e0
...
...
@@ -248,12 +248,11 @@ internal static partial class DeclarationFinder
{
var
list
=
ArrayBuilder
<
SymbolAndProjectId
>.
GetInstance
();
using
(
var
query
=
SearchQuery
.
Create
(
name
,
ignoreCase
))
{
await
AddCompilationDeclarationsWithNormalQueryAsync
(
project
,
query
,
filter
,
list
,
cancellationToken
).
ConfigureAwait
(
false
);
return
list
.
ToImmutableAndFree
();
}
using
var
query
=
SearchQuery
.
Create
(
name
,
ignoreCase
);
await
AddCompilationDeclarationsWithNormalQueryAsync
(
project
,
query
,
filter
,
list
,
cancellationToken
).
ConfigureAwait
(
false
);
return
list
.
ToImmutableAndFree
();
}
private
static
async
Task
<
ImmutableArray
<
SymbolAndProjectId
>>
FindSourceDeclarationsWithPatternInCurrentProcessAsync
(
...
...
@@ -273,27 +272,25 @@ internal static partial class DeclarationFinder
// If we don't have a dot in the pattern, just make a pattern matcher for the entire
// pattern they passed in. Otherwise, make a pattern matcher just for the part after
// the dot.
using
(
var
nameMatcher
=
PatternMatcher
.
CreatePatternMatcher
(
namePart
,
includeMatchedSpans
:
false
))
using
(
var
query
=
SearchQuery
.
CreateCustom
(
nameMatcher
.
Matches
))
using
var
nameMatcher
=
PatternMatcher
.
CreatePatternMatcher
(
namePart
,
includeMatchedSpans
:
false
);
using
var
query
=
SearchQuery
.
CreateCustom
(
nameMatcher
.
Matches
);
var
symbolAndProjectIds
=
await
searchAsync
(
query
).
ConfigureAwait
(
false
);
if
(
symbolAndProjectIds
.
Length
==
0
||
!
isDottedPattern
)
{
var
symbolAndProjectIds
=
await
searchAsync
(
query
).
ConfigureAwait
(
false
);
if
(
symbolAndProjectIds
.
Length
==
0
||
!
isDottedPattern
)
{
// If it wasn't a dotted pattern, or we didn't get anything back, then we're done.
// We can just return whatever set of results we got so far.
return
symbolAndProjectIds
;
}
// Ok, we had a dotted pattern. Have to see if the symbol's container matches the
// pattern as well.
using
(
var
containerPatternMatcher
=
PatternMatcher
.
CreateDotSeparatedContainerMatcher
(
containerPart
))
{
return
symbolAndProjectIds
.
WhereAsArray
(
t
=>
containerPatternMatcher
.
Matches
(
GetContainer
(
t
.
Symbol
)));
}
// If it wasn't a dotted pattern, or we didn't get anything back, then we're done.
// We can just return whatever set of results we got so far.
return
symbolAndProjectIds
;
}
// Ok, we had a dotted pattern. Have to see if the symbol's container matches the
// pattern as well.
using
var
containerPatternMatcher
=
PatternMatcher
.
CreateDotSeparatedContainerMatcher
(
containerPart
);
return
symbolAndProjectIds
.
WhereAsArray
(
t
=>
containerPatternMatcher
.
Matches
(
GetContainer
(
t
.
Symbol
)));
}
internal
static
Task
<
ImmutableArray
<
SymbolAndProjectId
>>
FindSourceDeclarationsWithPatternInCurrentProcessAsync
(
...
...
src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs
浏览文件 @
94ee71e0
...
...
@@ -78,13 +78,12 @@ public Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Cancella
var
solution
=
await
GetSolutionAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
project
=
solution
.
GetProject
(
projectId
);
using
(
var
query
=
SearchQuery
.
Create
(
name
,
searchKind
))
{
var
result
=
await
DeclarationFinder
.
FindAllDeclarationsWithNormalQueryInCurrentProcessAsync
(
project
,
query
,
criteria
,
cancellationToken
).
ConfigureAwait
(
false
);
using
var
query
=
SearchQuery
.
Create
(
name
,
searchKind
);
return
(
IList
<
SerializableSymbolAndProjectId
>)
result
.
SelectAsArray
(
SerializableSymbolAndProjectId
.
Dehydrate
);
}
var
result
=
await
DeclarationFinder
.
FindAllDeclarationsWithNormalQueryInCurrentProcessAsync
(
project
,
query
,
criteria
,
cancellationToken
).
ConfigureAwait
(
false
);
return
(
IList
<
SerializableSymbolAndProjectId
>)
result
.
SelectAsArray
(
SerializableSymbolAndProjectId
.
Dehydrate
);
}
},
cancellationToken
);
}
...
...
src/Workspaces/Remote/ServiceHub/Services/SnapshotService.JsonRpcAssetSource.cs
浏览文件 @
94ee71e0
...
...
@@ -83,33 +83,32 @@ private bool ReportUnlessCanceled(Exception ex, CancellationToken cancellationTo
{
var
results
=
new
List
<(
Checksum
,
object
)>();
using
(
var
reader
=
ObjectReader
.
TryGetReader
(
stream
,
cancellationToken
))
{
Debug
.
Assert
(
reader
!=
null
,
using
var
reader
=
ObjectReader
.
TryGetReader
(
stream
,
cancellationToken
);
Debug
.
Assert
(
reader
!=
null
,
@"We only ge a reader for data transmitted between live processes.
This data should always be correct as we're never persisting the data between sessions."
);
var
responseScopeId
=
reader
.
ReadInt32
();
Contract
.
ThrowIfFalse
(
scopeId
==
responseScopeId
);
var
responseScopeId
=
reader
.
ReadInt32
();
Contract
.
ThrowIfFalse
(
scopeId
==
responseScopeId
);
var
count
=
reader
.
ReadInt32
();
Contract
.
ThrowIfFalse
(
count
==
checksums
.
Count
);
for
(
var
i
=
0
;
i
<
count
;
i
++)
{
var
responseChecksum
=
Checksum
.
ReadFrom
(
reader
);
Contract
.
ThrowIfFalse
(
checksums
.
Contains
(
responseChecksum
));
var
count
=
reader
.
ReadInt32
();
Contract
.
ThrowIfFalse
(
count
==
checksums
.
Count
);
var
kind
=
(
WellKnownSynchronizationKind
)
reader
.
ReadInt32
();
for
(
var
i
=
0
;
i
<
count
;
i
++)
{
var
responseChecksum
=
Checksum
.
ReadFrom
(
reader
);
Contract
.
ThrowIfFalse
(
checksums
.
Contains
(
responseChecksum
));
// in service hub, cancellation means simply closed stream
var
@object
=
serializerService
.
Deserialize
<
object
>(
kind
,
reader
,
cancellationToken
);
var
kind
=
(
WellKnownSynchronizationKind
)
reader
.
ReadInt32
();
results
.
Add
((
responseChecksum
,
@object
));
}
// in service hub, cancellation means simply closed stream
var
@object
=
serializerService
.
Deserialize
<
object
>(
kind
,
reader
,
cancellationToken
);
re
turn
results
;
re
sults
.
Add
((
responseChecksum
,
@object
))
;
}
return
results
;
}
private
static
string
GetRequestLogInfo
(
int
serviceId
,
IEnumerable
<
Checksum
>
checksums
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录