Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f8cdc451
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,发现更多精彩内容 >>
提交
f8cdc451
编写于
3月 16, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
temp
上级
91d28320
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
16 deletion
+20
-16
src/VisualStudio/Core/Def/Implementation/TodoComment/VisualStudioTodoCommentService.cs
...lementation/TodoComment/VisualStudioTodoCommentService.cs
+17
-15
src/VisualStudio/Core/Def/Implementation/TodoComment/VisualStudioTodoCommentServiceFactory.cs
...tion/TodoComment/VisualStudioTodoCommentServiceFactory.cs
+3
-1
未找到文件。
src/VisualStudio/Core/Def/Implementation/TodoComment/VisualStudioTodoCommentService.cs
浏览文件 @
f8cdc451
...
...
@@ -5,6 +5,7 @@
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -15,6 +16,7 @@
using
Microsoft.CodeAnalysis.ProjectTelemetry
;
using
Microsoft.CodeAnalysis.Remote
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.TodoComment
;
using
Microsoft.CodeAnalysis.TodoComments
;
using
Microsoft.Internal.VisualStudio.Shell
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
;
...
...
@@ -36,7 +38,7 @@ internal class VisualStudioTodoCommentService
/// <summary>
/// Queue where we enqueue the information we get from OOP to process in batch in the future.
/// </summary>
private
AsyncBatchingWorkQueue
<
ProjectTelemetry
Info
>
_workQueue
=
null
!;
private
AsyncBatchingWorkQueue
<
TodoComment
Info
>
_workQueue
=
null
!;
public
VisualStudioTodoCommentService
(
VisualStudioWorkspaceImpl
workspace
,
IThreadingContext
threadingContext
)
:
base
(
threadingContext
)
=>
_workspace
=
workspace
;
...
...
@@ -65,9 +67,9 @@ private async Task StartAsync(CancellationToken cancellationToken)
private
async
Task
StartWorkerAsync
(
CancellationToken
cancellationToken
)
{
_workQueue
=
new
AsyncBatchingWorkQueue
<
ProjectTelemetry
Info
>(
_workQueue
=
new
AsyncBatchingWorkQueue
<
TodoComment
Info
>(
TimeSpan
.
FromSeconds
(
1
),
NotifyTelemetryService
Async
,
ProcessTodoCommentInfos
Async
,
cancellationToken
);
var
client
=
await
RemoteHostClient
.
TryGetClientAsync
(
_workspace
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -84,7 +86,7 @@ private async Task StartWorkerAsync(CancellationToken cancellationToken)
// Now kick off scanning in the OOP process.
var
success
=
await
_keepAliveSession
.
TryInvokeAsync
(
nameof
(
IRemoteTodoComment
s
Service
.
ComputeTodoCommentsAsync
),
nameof
(
IRemoteTodoCommentService
.
ComputeTodoCommentsAsync
),
solution
:
null
,
arguments
:
Array
.
Empty
<
object
>(),
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -93,18 +95,18 @@ private async Task StartWorkerAsync(CancellationToken cancellationToken)
/// <summary>
/// Callback from the OOP service back into us.
/// </summary>
public
Task
Re
gisterProjectTelemetryInfoAsync
(
ProjectTelemetryInfo
info
,
CancellationToken
cancellationToken
)
public
Task
Re
portTodoCommentsAsync
(
List
<
TodoCommentInfo
>
infos
,
CancellationToken
cancellationToken
)
{
_workQueue
.
AddWork
(
info
);
_workQueue
.
AddWork
(
info
s
);
return
Task
.
CompletedTask
;
}
private
async
Task
NotifyTelemetryService
Async
(
ImmutableArray
<
ProjectTelemetry
Info
>
infos
,
CancellationToken
cancellationToken
)
private
async
Task
ProcessTodoCommentInfos
Async
(
ImmutableArray
<
TodoComment
Info
>
infos
,
CancellationToken
cancellationToken
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
using
var
_1
=
ArrayBuilder
<
ProjectTelemetry
Info
>.
GetInstance
(
out
var
filteredInfos
);
using
var
_1
=
ArrayBuilder
<
TodoComment
Info
>.
GetInstance
(
out
var
filteredInfos
);
AddFilteredInfos
(
infos
,
filteredInfos
);
using
var
_2
=
ArrayBuilder
<
Task
>.
GetInstance
(
out
var
tasks
);
...
...
@@ -114,22 +116,22 @@ public Task RegisterProjectTelemetryInfoAsync(ProjectTelemetryInfo info, Cancell
await
Task
.
WhenAll
(
tasks
).
ConfigureAwait
(
false
);
}
private
void
AddFilteredInfos
(
ImmutableArray
<
ProjectTelemetryInfo
>
infos
,
ArrayBuilder
<
ProjectTelemetry
Info
>
filteredInfos
)
private
void
AddFilteredInfos
(
ImmutableArray
<
TodoCommentInfo
>
infos
,
ArrayBuilder
<
TodoComment
Info
>
filteredInfos
)
{
using
var
_
=
PooledHashSet
<
Projec
tId
>.
GetInstance
(
out
var
seenProjectIds
);
using
var
_
=
PooledHashSet
<
Documen
tId
>.
GetInstance
(
out
var
seenProjectIds
);
// Walk the list of telemetry items in reverse, and skip any items for a
projec
t once
// Walk the list of telemetry items in reverse, and skip any items for a
documen
t once
// we've already seen it once. That way, we're only reporting the most up to date
// information for a
projec
t, and we're skipping the stale information.
// information for a
documen
t, and we're skipping the stale information.
for
(
var
i
=
infos
.
Length
-
1
;
i
>=
0
;
i
--)
{
var
info
=
infos
[
i
];
if
(
seenProjectIds
.
Add
(
info
.
Projec
tId
))
if
(
seenProjectIds
.
Add
(
info
.
Documen
tId
))
filteredInfos
.
Add
(
info
);
}
}
private
void
NotifyTelemetryService
(
ProjectTelemetryInfo
info
)
private
void
ProcessTodoCommentInfosAsync
(
ProjectTelemetryInfo
info
)
{
try
{
...
...
src/VisualStudio/Core/Def/Implementation/TodoComment/VisualStudioTodoCommentServiceFactory.cs
浏览文件 @
f8cdc451
...
...
@@ -6,6 +6,7 @@
using
System
;
using
System.Composition
;
using
Microsoft.CodeAnalysis.Editor
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host.Mef
;
...
...
@@ -13,8 +14,9 @@
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TodoComment
{
[
Export
(
typeof
(
ITodoListProvider
))]
[
ExportWorkspaceServiceFactory
(
typeof
(
ITodoCommentService
),
ServiceLayer
.
Host
),
Shared
]
internal
class
VisualStudioTodoCommentServiceFactory
:
IWorkspaceServiceFactory
internal
class
VisualStudioTodoCommentServiceFactory
:
IWorkspaceServiceFactory
,
ITodoListProvider
{
private
readonly
IThreadingContext
_threadingContext
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录