Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c5b5048f
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,发现更多精彩内容 >>
提交
c5b5048f
编写于
10月 18, 2019
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review feedback
上级
10696f7f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
11 deletion
+18
-11
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
+4
-1
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
...pilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
+5
-2
src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
...e/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
+4
-3
src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs
...table/DiagnosticAnalyzer/SuppressMessageAttributeState.cs
+5
-5
未找到文件。
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
浏览文件 @
c5b5048f
...
...
@@ -341,7 +341,10 @@ public SuppressionInfo GetSuppressionInfo(Compilation compilation)
AttributeData
attribute
;
var
suppressMessageState
=
new
SuppressMessageAttributeState
(
compilation
);
if
(!
suppressMessageState
.
IsDiagnosticSuppressed
(
this
,
getSemanticModel
:
tree
=>
compilation
.
GetSemanticModel
(
tree
),
out
attribute
))
if
(!
suppressMessageState
.
IsDiagnosticSuppressed
(
this
,
getSemanticModel
:
(
compilation
,
tree
)
=>
compilation
.
GetSemanticModel
(
tree
),
out
attribute
))
{
attribute
=
null
;
}
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
浏览文件 @
c5b5048f
...
...
@@ -660,7 +660,10 @@ public async Task<ImmutableArray<Diagnostic>> GetDiagnosticsAsync(Compilation co
}
private
SemanticModel
GetOrCreateSemanticModel
(
SyntaxTree
tree
)
=>
CurrentCompilationData
.
GetOrCreateCachedSemanticModel
(
tree
,
AnalyzerExecutor
.
Compilation
,
AnalyzerExecutor
.
CancellationToken
);
=>
GetOrCreateSemanticModel
(
AnalyzerExecutor
.
Compilation
,
tree
);
private
SemanticModel
GetOrCreateSemanticModel
(
Compilation
compilation
,
SyntaxTree
tree
)
=>
CurrentCompilationData
.
GetOrCreateCachedSemanticModel
(
tree
,
compilation
,
AnalyzerExecutor
.
CancellationToken
);
public
void
ApplyProgrammaticSuppressions
(
DiagnosticBag
reportedDiagnostics
,
Compilation
compilation
)
{
...
...
@@ -828,7 +831,7 @@ private ImmutableArray<Diagnostic> FilterDiagnosticsSuppressedInSourceOrByAnalyz
ImmutableArray
<
Diagnostic
>
diagnostics
,
Compilation
compilation
,
SuppressMessageAttributeState
suppressMessageState
,
Func
<
SyntaxTree
,
SemanticModel
>
getSemanticModel
)
Func
<
Compilation
,
SyntaxTree
,
SemanticModel
>
getSemanticModel
)
{
if
(
diagnostics
.
IsEmpty
)
{
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
浏览文件 @
c5b5048f
...
...
@@ -1156,7 +1156,7 @@ private static IEnumerable<Diagnostic> GetEffectiveDiagnosticsImpl(ImmutableArra
}
var
suppressMessageState
=
new
SuppressMessageAttributeState
(
compilation
);
var
semanticModelsByTree
=
new
Concurrent
Dictionary
<
SyntaxTree
,
SemanticModel
>();
var
semanticModelsByTree
=
new
Dictionary
<
SyntaxTree
,
SemanticModel
>();
foreach
(
var
diagnostic
in
diagnostics
)
{
if
(
diagnostic
!=
null
)
...
...
@@ -1169,11 +1169,12 @@ private static IEnumerable<Diagnostic> GetEffectiveDiagnosticsImpl(ImmutableArra
}
}
SemanticModel
getSemanticModel
(
SyntaxTree
tree
)
SemanticModel
getSemanticModel
(
Compilation
compilation
,
SyntaxTree
tree
)
{
if
(!
semanticModelsByTree
.
TryGetValue
(
tree
,
out
var
model
))
{
model
=
semanticModelsByTree
.
GetOrAdd
(
tree
,
compilation
.
GetSemanticModel
(
tree
));
model
=
compilation
.
GetSemanticModel
(
tree
);
semanticModelsByTree
.
Add
(
tree
,
model
);
}
return
model
;
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs
浏览文件 @
c5b5048f
...
...
@@ -99,7 +99,7 @@ internal SuppressMessageAttributeState(Compilation compilation)
_localSuppressionsBySymbol
=
new
ConcurrentDictionary
<
ISymbol
,
ImmutableDictionary
<
string
,
SuppressMessageInfo
>>();
}
public
Diagnostic
ApplySourceSuppressions
(
Diagnostic
diagnostic
,
Func
<
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
ISymbol
symbolOpt
=
null
)
public
Diagnostic
ApplySourceSuppressions
(
Diagnostic
diagnostic
,
Func
<
Compilation
,
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
ISymbol
symbolOpt
=
null
)
{
if
(
diagnostic
.
IsSuppressed
)
{
...
...
@@ -117,7 +117,7 @@ public Diagnostic ApplySourceSuppressions(Diagnostic diagnostic, Func<SyntaxTree
return
diagnostic
;
}
public
bool
IsDiagnosticSuppressed
(
Diagnostic
diagnostic
,
Func
<
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
AttributeData
suppressingAttribute
)
public
bool
IsDiagnosticSuppressed
(
Diagnostic
diagnostic
,
Func
<
Compilation
,
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
AttributeData
suppressingAttribute
)
{
SuppressMessageInfo
info
;
if
(
IsDiagnosticSuppressed
(
diagnostic
,
getSemanticModel
,
out
info
))
...
...
@@ -130,10 +130,10 @@ public bool IsDiagnosticSuppressed(Diagnostic diagnostic, Func<SyntaxTree, Seman
return
false
;
}
private
bool
IsDiagnosticSuppressed
(
Diagnostic
diagnostic
,
Func
<
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
SuppressMessageInfo
info
)
private
bool
IsDiagnosticSuppressed
(
Diagnostic
diagnostic
,
Func
<
Compilation
,
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
SuppressMessageInfo
info
)
=>
IsDiagnosticSuppressed
(
diagnostic
.
Id
,
diagnostic
.
Location
,
getSemanticModel
,
out
info
);
private
bool
IsDiagnosticSuppressed
(
string
id
,
Location
location
,
Func
<
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
SuppressMessageInfo
info
)
private
bool
IsDiagnosticSuppressed
(
string
id
,
Location
location
,
Func
<
Compilation
,
SyntaxTree
,
SemanticModel
>
getSemanticModel
,
out
SuppressMessageInfo
info
)
{
Debug
.
Assert
(
id
!=
null
);
Debug
.
Assert
(
location
!=
null
);
...
...
@@ -148,7 +148,7 @@ private bool IsDiagnosticSuppressed(string id, Location location, Func<SyntaxTre
// Walk up the syntax tree checking for suppression by any declared symbols encountered
if
(
location
.
IsInSource
)
{
var
model
=
getSemanticModel
(
location
.
SourceTree
);
var
model
=
getSemanticModel
(
_compilation
,
location
.
SourceTree
);
bool
inImmediatelyContainingSymbol
=
true
;
for
(
var
node
=
location
.
SourceTree
.
GetRoot
().
FindNode
(
location
.
SourceSpan
,
getInnermostNodeForTie
:
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录