Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e5b8a1b3
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,发现更多精彩内容 >>
提交
e5b8a1b3
编写于
11月 13, 2019
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add work coordinator unit tests for different background analysis scopes
上级
cc090d1f
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
503 addition
and
154 deletion
+503
-154
src/EditorFeatures/Test/Diagnostics/DiagnosticDataTests.cs
src/EditorFeatures/Test/Diagnostics/DiagnosticDataTests.cs
+1
-1
src/EditorFeatures/Test/SolutionCrawler/TestDocumentTrackingService.cs
...tures/Test/SolutionCrawler/TestDocumentTrackingService.cs
+63
-0
src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
...itorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
+420
-146
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
.../SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
+9
-0
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
...onCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
+8
-5
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.WorkItem.cs
...Core/Portable/SolutionCrawler/WorkCoordinator.WorkItem.cs
+2
-2
未找到文件。
src/EditorFeatures/Test/Diagnostics/DiagnosticDataTests.cs
浏览文件 @
e5b8a1b3
...
...
@@ -74,7 +74,7 @@ public async Task DiagnosticData_GetText6()
await
VerifyTextSpanAsync
(
code
,
1
,
30
,
2
,
40
,
new
TextSpan
(
code
.
Length
,
0
));
}
[
Fact
,
Trait
(
T
est
.
Utilities
.
Traits
.
Feature
,
Test
.
Utilities
.
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
T
raits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
async
Task
DiagnosticData_GetText7
()
{
var
code
=
@"
...
...
src/EditorFeatures/Test/SolutionCrawler/TestDocumentTrackingService.cs
0 → 100644
浏览文件 @
e5b8a1b3
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Immutable
;
using
System.Composition
;
using
Microsoft.CodeAnalysis.Host.Mef
;
namespace
Microsoft.CodeAnalysis.Editor.Test
{
[
ExportWorkspaceService
(
typeof
(
IDocumentTrackingService
)),
Shared
]
internal
sealed
class
TestDocumentTrackingService
:
IDocumentTrackingService
{
private
readonly
object
_gate
=
new
object
();
private
event
EventHandler
<
DocumentId
>
_activeDocumentChangedEventHandler
;
private
DocumentId
_activeDocumentId
;
[
ImportingConstructor
]
public
TestDocumentTrackingService
()
{
}
public
event
EventHandler
<
DocumentId
>
ActiveDocumentChanged
{
add
{
lock
(
_gate
)
{
_activeDocumentChangedEventHandler
+=
value
;
}
}
remove
{
lock
(
_gate
)
{
_activeDocumentChangedEventHandler
-=
value
;
}
}
}
public
event
EventHandler
<
EventArgs
>
NonRoslynBufferTextChanged
{
add
{
}
remove
{
}
}
public
void
SetActiveDocument
(
DocumentId
newActiveDocumentId
)
{
_activeDocumentId
=
newActiveDocumentId
;
_activeDocumentChangedEventHandler
?.
Invoke
(
this
,
newActiveDocumentId
);
}
public
DocumentId
TryGetActiveDocument
()
{
return
_activeDocumentId
;
}
public
ImmutableArray
<
DocumentId
>
GetVisibleDocuments
()
{
return
_activeDocumentId
!=
null
?
ImmutableArray
.
Create
(
_activeDocumentId
)
:
ImmutableArray
<
DocumentId
>.
Empty
;
}
}
}
src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
浏览文件 @
e5b8a1b3
此差异已折叠。
点击以展开。
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
浏览文件 @
e5b8a1b3
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
...
...
@@ -75,6 +76,12 @@ public void Enqueue(WorkItem item)
{
Contract
.
ThrowIfFalse
(
item
.
DocumentId
!=
null
,
"can only enqueue a document work item"
);
// Don't enqueue item if we don't have any high priority analyzers
if
(
this
.
Analyzers
.
IsEmpty
)
{
return
;
}
// we only put workitem in high priority queue if there is a text change.
// this is to prevent things like opening a file, changing in other files keep enqueuing
// expensive high priority work.
...
...
@@ -110,6 +117,8 @@ protected override Task WaitAsync(CancellationToken cancellationToken)
protected
override
async
Task
ExecuteAsync
()
{
Debug
.
Assert
(!
Analyzers
.
IsEmpty
);
if
(
CancellationToken
.
IsCancellationRequested
)
{
return
;
...
...
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
浏览文件 @
e5b8a1b3
...
...
@@ -116,20 +116,22 @@ public void Enqueue(WorkItem item)
}
else
{
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_highPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
out
var
newWorkItem
))
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_highPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
_listener
,
out
var
newWorkItem
))
{
_highPriorityProcessor
.
Enqueue
(
newWorkItem
.
Value
);
}
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_normalPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
out
newWorkItem
))
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_normalPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
_listener
,
out
newWorkItem
))
{
_normalPriorityProcessor
.
Enqueue
(
newWorkItem
.
Value
);
}
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_lowPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
out
newWorkItem
))
if
(
TryGetItemWithOverriddenAnalysisScope
(
item
,
_lowPriorityProcessor
.
Analyzers
,
options
,
analysisScope
,
_listener
,
out
newWorkItem
))
{
_lowPriorityProcessor
.
Enqueue
(
newWorkItem
.
Value
);
}
item
.
AsyncToken
.
Dispose
();
}
ReportPendingWorkItemCount
();
...
...
@@ -151,7 +153,7 @@ bool ShouldEnqueueForAllQueues(WorkItem item, BackgroundAnalysisScope analysisSc
!
reasons
.
Contains
(
PredefinedInvocationReasons
.
DocumentClosed
)
&&
!
reasons
.
Contains
(
PredefinedInvocationReasons
.
DocumentRemoved
))
{
return
item
.
DocumentId
==
_documentTracker
.
TryGetActiveDocument
();
return
item
.
DocumentId
==
_documentTracker
?
.
TryGetActiveDocument
();
}
return
true
;
...
...
@@ -163,6 +165,7 @@ bool ShouldEnqueueForAllQueues(WorkItem item, BackgroundAnalysisScope analysisSc
ImmutableArray
<
IIncrementalAnalyzer
>
allAnalyzers
,
OptionSet
options
,
BackgroundAnalysisScope
analysisScope
,
IAsynchronousOperationListener
listener
,
[
NotNullWhen
(
returnValue
:
true
)]
out
WorkItem
?
newWorkItem
)
{
var
analyzersToExecute
=
item
.
GetApplicableAnalyzers
(
allAnalyzers
);
...
...
@@ -173,7 +176,7 @@ bool ShouldEnqueueForAllQueues(WorkItem item, BackgroundAnalysisScope analysisSc
if
(!
analyzersWithOverriddenAnalysisScope
.
IsEmpty
)
{
newWorkItem
=
item
.
With
(
analyzersWithOverriddenAnalysisScope
);
newWorkItem
=
item
.
With
(
analyzersWithOverriddenAnalysisScope
,
listener
.
BeginAsyncOperation
(
"WorkItem"
)
);
return
true
;
}
...
...
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.WorkItem.cs
浏览文件 @
e5b8a1b3
...
...
@@ -174,10 +174,10 @@ public WorkItem With(DocumentId documentId, ProjectId projectId, IAsyncToken asy
asyncToken
);
}
public
WorkItem
With
(
ImmutableHashSet
<
IIncrementalAnalyzer
>
specificAnalyzers
)
public
WorkItem
With
(
ImmutableHashSet
<
IIncrementalAnalyzer
>
specificAnalyzers
,
IAsyncToken
asyncToken
)
{
return
new
WorkItem
(
DocumentId
,
ProjectId
,
Language
,
InvocationReasons
,
IsLowPriority
,
ActiveMember
,
specificAnalyzers
,
IsRetry
,
A
syncToken
);
IsLowPriority
,
ActiveMember
,
specificAnalyzers
,
IsRetry
,
a
syncToken
);
}
public
override
string
ToString
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录