Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0276b9b7
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
0276b9b7
编写于
8月 18, 2020
作者:
M
msftbot[bot]
提交者:
GitHub
8月 18, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #46922 from dotnet/merges/release/dev16.8-to-release/dev16.8-vs-deps
Merge release/dev16.8 to release/dev16.8-vs-deps
上级
beada515
1de1ba73
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
14 deletion
+59
-14
src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
...s/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
+53
-0
src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
...e/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
+6
-14
未找到文件。
src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
浏览文件 @
0276b9b7
...
...
@@ -611,5 +611,58 @@ void M2()
await
Task
.
WhenAll
(
tasks
);
}
[
Theory
,
WorkItem
(
46874
,
"https://github.com/dotnet/roslyn/pull/46874"
)]
[
InlineData
(
2
)]
[
InlineData
(
50
)]
public
async
Task
TestConcurrentGetAnalyzerDiagnostics_SymbolStartAnalyzer
(
int
partialDeclarationCount
)
{
var
sources
=
new
string
[
partialDeclarationCount
+
1
];
for
(
var
i
=
0
;
i
<
partialDeclarationCount
;
i
++)
{
sources
[
i
]
=
$@"
partial class C
{{
void
M
{
i
}()
{{
// warning CS0168: The variable 'x' is declared but never used.
int
x
;
}}
}}
"
;
}
sources
[
partialDeclarationCount
]
=
@"
class C3
{
void M2()
{
// warning CS0168: The variable 'x' is declared but never used.
int x;
}
}
"
;
var
compilation
=
CreateCompilation
(
sources
);
compilation
=
compilation
.
WithOptions
(
compilation
.
Options
.
WithConcurrentBuild
(
true
));
var
analyzers
=
ImmutableArray
.
Create
<
DiagnosticAnalyzer
>(
new
SymbolStartAnalyzer
(
topLevelAction
:
false
,
SymbolKind
.
NamedType
,
OperationKind
.
VariableDeclaration
));
var
compilationWithAnalyzers
=
compilation
.
WithAnalyzers
(
analyzers
,
new
CompilationWithAnalyzersOptions
(
new
AnalyzerOptions
(
ImmutableArray
<
AdditionalText
>.
Empty
),
onAnalyzerException
:
null
,
concurrentAnalysis
:
true
,
logAnalyzerExecutionTime
:
false
));
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
,
true
);
var
tasks
=
new
Task
[
10
];
for
(
var
i
=
0
;
i
<
10
;
i
++)
{
tasks
[
i
]
=
Task
.
Run
(()
=>
compilationWithAnalyzers
.
GetAnalyzerSemanticDiagnosticsAsync
(
model
,
null
,
CancellationToken
.
None
));
}
await
Task
.
WhenAll
(
tasks
);
}
}
}
src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
浏览文件 @
0276b9b7
...
...
@@ -687,23 +687,15 @@ private async Task ComputeAnalyzerSemanticDiagnosticsAsync(SemanticModel model,
Func
<
ImmutableArray
<
CompilationEvent
>>
getPendingEvents
=
()
=>
_analysisState
.
GetPendingEvents
(
analysisScope
.
Analyzers
,
model
.
SyntaxTree
,
cancellationToken
);
// Compute the analyzer diagnostics for the given analysis scope.
// We need to loop till symbol analysis is complete for any partial symbols being processed for other tree diagnostic requests.
do
{
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
(
ImmutableArray
<
CompilationEvent
>
compilationEvents
,
bool
hasSymbolStartActions
)
=
await
ComputeAnalyzerDiagnosticsAsync
(
pendingAnalysisScope
,
getPendingEvents
,
taskToken
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
hasSymbolStartActions
&&
forceCompletePartialTrees
)
{
await
processPartialSymbolLocationsAsync
(
compilationEvents
,
analysisScope
).
ConfigureAwait
(
false
);
}
}
while
(
_analysisOptions
.
ConcurrentAnalysis
&&
_analysisState
.
HasPendingSymbolAnalysis
(
pendingAnalysisScope
,
cancellationToken
));
// Compute the analyzer diagnostics for the given analysis scope.
(
ImmutableArray
<
CompilationEvent
>
compilationEvents
,
bool
hasSymbolStartActions
)
=
await
ComputeAnalyzerDiagnosticsAsync
(
pendingAnalysisScope
,
getPendingEvents
,
taskToken
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
_analysisOptions
.
ConcurrentAnalysis
)
// If required, force compute diagnostics for partial symbol locations.
if
(
hasSymbolStartActions
&&
forceCompletePartialTrees
)
{
// Wait for all active tree tasks as they might still be reporting diagnostics for partial symbols defined in this tree.
await
WaitForActiveAnalysisTasksAsync
(
waitForTreeTasks
:
true
,
waitForCompilationOrNonConcurrentTask
:
false
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
await
processPartialSymbolLocationsAsync
(
compilationEvents
,
analysisScope
).
ConfigureAwait
(
false
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录