Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ca5b0d9e
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,发现更多精彩内容 >>
提交
ca5b0d9e
编写于
6月 13, 2017
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address PR feedback
上级
67ad810c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
43 deletion
+25
-43
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerManager.cs
...ilers/Core/Portable/DiagnosticAnalyzer/AnalyzerManager.cs
+0
-2
src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
...tics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
+8
-10
src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs
...tilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs
+8
-10
src/EditorFeatures/TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
...tUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
+8
-16
src/EditorFeatures/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
...TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
+1
-5
未找到文件。
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerManager.cs
浏览文件 @
ca5b0d9e
...
@@ -19,8 +19,6 @@ namespace Microsoft.CodeAnalysis.Diagnostics
...
@@ -19,8 +19,6 @@ namespace Microsoft.CodeAnalysis.Diagnostics
/// </summary>
/// </summary>
internal
partial
class
AnalyzerManager
internal
partial
class
AnalyzerManager
{
{
private
readonly
object
_gate
=
new
object
();
// This cache stores the analyzer execution context per-analyzer (i.e. registered actions, supported descriptors, etc.).
// This cache stores the analyzer execution context per-analyzer (i.e. registered actions, supported descriptors, etc.).
private
readonly
ImmutableDictionary
<
DiagnosticAnalyzer
,
AnalyzerExecutionContext
>
_analyzerExecutionContextMap
;
private
readonly
ImmutableDictionary
<
DiagnosticAnalyzer
,
AnalyzerExecutionContext
>
_analyzerExecutionContextMap
;
...
...
src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
浏览文件 @
ca5b0d9e
...
@@ -60,17 +60,15 @@ internal virtual (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderA
...
@@ -60,17 +60,15 @@ internal virtual (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderA
document
=
GetDocumentAndAnnotatedSpan
(
workspace
,
out
annotation
,
out
span
);
document
=
GetDocumentAndAnnotatedSpan
(
workspace
,
out
annotation
,
out
span
);
}
}
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
provider
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
provider
);
{
var
diagnostics
=
await
testDriver
.
GetAllDiagnosticsAsync
(
provider
,
document
,
span
);
var
diagnostics
=
await
testDriver
.
GetAllDiagnosticsAsync
(
provider
,
document
,
span
);
AssertNoAnalyzerExceptionDiagnostics
(
diagnostics
);
AssertNoAnalyzerExceptionDiagnostics
(
diagnostics
);
var
fixer
=
providerAndFixer
.
Item2
;
var
fixer
=
providerAndFixer
.
Item2
;
var
ids
=
new
HashSet
<
string
>(
fixer
.
FixableDiagnosticIds
);
var
ids
=
new
HashSet
<
string
>(
fixer
.
FixableDiagnosticIds
);
var
dxs
=
diagnostics
.
Where
(
d
=>
ids
.
Contains
(
d
.
Id
)).
ToList
();
var
dxs
=
diagnostics
.
Where
(
d
=>
ids
.
Contains
(
d
.
Id
)).
ToList
();
return
await
GetDiagnosticAndFixesAsync
(
return
await
GetDiagnosticAndFixesAsync
(
dxs
,
provider
,
fixer
,
testDriver
,
document
,
span
,
annotation
,
parameters
.
fixAllActionEquivalenceKey
);
dxs
,
provider
,
fixer
,
testDriver
,
document
,
span
,
annotation
,
parameters
.
fixAllActionEquivalenceKey
);
}
}
}
protected
async
Task
TestDiagnosticSeverityAndCountAsync
(
protected
async
Task
TestDiagnosticSeverityAndCountAsync
(
...
...
src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs
浏览文件 @
ca5b0d9e
...
@@ -71,18 +71,16 @@ private ImmutableArray<Diagnostic> FilterDiagnostics(IEnumerable<Diagnostic> dia
...
@@ -71,18 +71,16 @@ private ImmutableArray<Diagnostic> FilterDiagnostics(IEnumerable<Diagnostic> dia
document
=
GetDocumentAndAnnotatedSpan
(
workspace
,
out
annotation
,
out
span
);
document
=
GetDocumentAndAnnotatedSpan
(
workspace
,
out
annotation
,
out
span
);
}
}
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
provider
,
includeSuppressedDiagnostics
:
IncludeSuppressedDiagnostics
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
provider
,
includeSuppressedDiagnostics
:
IncludeSuppressedDiagnostics
);
{
var
fixer
=
providerAndFixer
.
Item2
;
var
fixer
=
providerAndFixer
.
Item2
;
var
diagnostics
=
(
await
testDriver
.
GetAllDiagnosticsAsync
(
provider
,
document
,
span
))
var
diagnostics
=
(
await
testDriver
.
GetAllDiagnosticsAsync
(
provider
,
document
,
span
))
.
Where
(
d
=>
fixer
.
CanBeSuppressedOrUnsuppressed
(
d
));
.
Where
(
d
=>
fixer
.
CanBeSuppressedOrUnsuppressed
(
d
));
var
filteredDiagnostics
=
FilterDiagnostics
(
diagnostics
);
var
filteredDiagnostics
=
FilterDiagnostics
(
diagnostics
);
var
wrapperCodeFixer
=
new
WrapperCodeFixProvider
(
fixer
,
filteredDiagnostics
.
Select
(
d
=>
d
.
Id
));
var
wrapperCodeFixer
=
new
WrapperCodeFixProvider
(
fixer
,
filteredDiagnostics
.
Select
(
d
=>
d
.
Id
));
return
await
GetDiagnosticAndFixesAsync
(
return
await
GetDiagnosticAndFixesAsync
(
filteredDiagnostics
,
provider
,
wrapperCodeFixer
,
testDriver
,
document
,
span
,
annotation
,
parameters
.
fixAllActionEquivalenceKey
);
filteredDiagnostics
,
provider
,
wrapperCodeFixer
,
testDriver
,
document
,
span
,
annotation
,
parameters
.
fixAllActionEquivalenceKey
);
}
}
}
}
}
}
}
src/EditorFeatures/TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
浏览文件 @
ca5b0d9e
...
@@ -12,18 +12,14 @@ public static class DiagnosticProviderTestUtilities
...
@@ -12,18 +12,14 @@ public static class DiagnosticProviderTestUtilities
{
{
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Document
document
,
TextSpan
span
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Document
document
,
TextSpan
span
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
{
{
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
);
{
return
await
testDriver
.
GetAllDiagnosticsAsync
(
workspaceAnalyzerOpt
,
document
,
span
);
return
await
testDriver
.
GetAllDiagnosticsAsync
(
workspaceAnalyzerOpt
,
document
,
span
);
}
}
}
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Project
project
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Project
project
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
{
{
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
);
{
return
await
testDriver
.
GetAllDiagnosticsAsync
(
workspaceAnalyzerOpt
,
project
);
return
await
testDriver
.
GetAllDiagnosticsAsync
(
workspaceAnalyzerOpt
,
project
);
}
}
}
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Solution
solution
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetAllDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Solution
solution
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
...
@@ -40,18 +36,14 @@ public static async Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Diagnos
...
@@ -40,18 +36,14 @@ public static async Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Diagnos
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetDocumentDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Document
document
,
TextSpan
span
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetDocumentDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Document
document
,
TextSpan
span
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
{
{
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
document
.
Project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
);
{
return
await
testDriver
.
GetDocumentDiagnosticsAsync
(
workspaceAnalyzerOpt
,
document
,
span
);
return
await
testDriver
.
GetDocumentDiagnosticsAsync
(
workspaceAnalyzerOpt
,
document
,
span
);
}
}
}
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetProjectDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Project
project
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
public
static
async
Task
<
IEnumerable
<
Diagnostic
>>
GetProjectDiagnosticsAsync
(
DiagnosticAnalyzer
workspaceAnalyzerOpt
,
Project
project
,
Action
<
Exception
,
DiagnosticAnalyzer
,
Diagnostic
>
onAnalyzerException
=
null
,
bool
logAnalyzerExceptionAsDiagnostics
=
false
,
bool
includeSuppressedDiagnostics
=
false
)
{
{
using
(
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
))
var
testDriver
=
new
TestDiagnosticAnalyzerDriver
(
project
,
workspaceAnalyzerOpt
,
onAnalyzerException
,
logAnalyzerExceptionAsDiagnostics
,
includeSuppressedDiagnostics
);
{
return
await
testDriver
.
GetProjectDiagnosticsAsync
(
workspaceAnalyzerOpt
,
project
);
return
await
testDriver
.
GetProjectDiagnosticsAsync
(
workspaceAnalyzerOpt
,
project
);
}
}
}
}
}
}
}
src/EditorFeatures/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
浏览文件 @
ca5b0d9e
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
namespace
Microsoft.CodeAnalysis.UnitTests.Diagnostics
namespace
Microsoft.CodeAnalysis.UnitTests.Diagnostics
{
{
public
class
TestDiagnosticAnalyzerDriver
:
IDisposable
public
class
TestDiagnosticAnalyzerDriver
{
{
private
readonly
ImmutableArray
<
DiagnosticAnalyzer
>
_workspaceAnalyzers
;
private
readonly
ImmutableArray
<
DiagnosticAnalyzer
>
_workspaceAnalyzers
;
private
readonly
TestDiagnosticAnalyzerService
_diagnosticAnalyzerService
;
private
readonly
TestDiagnosticAnalyzerService
_diagnosticAnalyzerService
;
...
@@ -113,9 +113,5 @@ public Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(DiagnosticAnalyz
...
@@ -113,9 +113,5 @@ public Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(DiagnosticAnalyz
{
{
return
GetDiagnosticsAsync
(
workspaceAnalyzerOpt
,
null
,
default
(
TextSpan
),
project
,
getDocumentDiagnostics
:
false
,
getProjectDiagnostics
:
true
);
return
GetDiagnosticsAsync
(
workspaceAnalyzerOpt
,
null
,
default
(
TextSpan
),
project
,
getDocumentDiagnostics
:
false
,
getProjectDiagnostics
:
true
);
}
}
public
void
Dispose
()
{
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录