Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
50f8500d
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,发现更多精彩内容 >>
提交
50f8500d
编写于
5月 17, 2016
作者:
N
Nick Guerrera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent duplicate rule metadata in /errorlog
上级
fab958dc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
227 addition
and
1 deletion
+227
-1
src/Compilers/Core/CodeAnalysisTest/Diagnostics/ErrorLoggerTests.cs
...ers/Core/CodeAnalysisTest/Diagnostics/ErrorLoggerTests.cs
+178
-0
src/Compilers/Core/Portable/CommandLine/ErrorLogger.cs
src/Compilers/Core/Portable/CommandLine/ErrorLogger.cs
+49
-1
未找到文件。
src/Compilers/Core/CodeAnalysisTest/Diagnostics/ErrorLoggerTests.cs
浏览文件 @
50f8500d
...
...
@@ -93,10 +93,25 @@ public void AdditionalLocationsAsRelatedLocations()
public
void
DescriptorIdCollision
()
{
var
descriptors
=
new
[]
{
// Toughest case: generation of TST001.001 collides with with actual TST001.001 and must be bumped to TST00.002
new
DiagnosticDescriptor
(
"TST001.001"
,
"_TST001.001_"
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST001"
,
"_TST001_"
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST001"
,
"_TST001.002_"
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST001"
,
"_TST001.003_"
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
// Descriptors with same values should not get distinct entries in log
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
// Changing only the message format (which we do not write out) should not produce a distinct entry in log.
new
DiagnosticDescriptor
(
"TST002"
,
""
,
"messageFormat"
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
// Changing any property that we do write out should create a distinct entry
new
DiagnosticDescriptor
(
"TST002"
,
"title_001"
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
"category_002"
,
DiagnosticSeverity
.
Warning
,
true
),
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
""
,
DiagnosticSeverity
.
Error
/*003*/
,
true
),
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
isEnabledByDefault
:
false
/*004*/
),
new
DiagnosticDescriptor
(
"TST002"
,
""
,
""
,
""
,
DiagnosticSeverity
.
Warning
,
true
,
"description_005"
),
};
var
stream
=
new
MemoryStream
();
...
...
@@ -154,6 +169,65 @@ public void DescriptorIdCollision()
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""message"": ""messageFormat"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.001"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.003"",
""level"": ""error""
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.004"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.005"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST001.001"",
""level"": ""warning"",
...
...
@@ -183,6 +257,65 @@ public void DescriptorIdCollision()
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""level"": ""warning"",
""message"": ""messageFormat"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.001"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.002"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.003"",
""level"": ""error""
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.004"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
},
{
""ruleId"": ""TST002"",
""ruleKey"": ""TST002.005"",
""level"": ""warning"",
""properties"": {
""warningLevel"": 1
}
}
],
""rules"": {
...
...
@@ -217,6 +350,51 @@ public void DescriptorIdCollision()
""properties"": {
""isEnabledByDefault"": true
}
},
""TST002"": {
""id"": ""TST002"",
""defaultLevel"": ""warning"",
""properties"": {
""isEnabledByDefault"": true
}
},
""TST002.001"": {
""id"": ""TST002"",
""shortDescription"": ""title_001"",
""defaultLevel"": ""warning"",
""properties"": {
""isEnabledByDefault"": true
}
},
""TST002.002"": {
""id"": ""TST002"",
""defaultLevel"": ""warning"",
""properties"": {
""category"": ""category_002"",
""isEnabledByDefault"": true
}
},
""TST002.003"": {
""id"": ""TST002"",
""defaultLevel"": ""error"",
""properties"": {
""isEnabledByDefault"": true
}
},
""TST002.004"": {
""id"": ""TST002"",
""defaultLevel"": ""warning"",
""properties"": {
""isEnabledByDefault"": false
}
},
""TST002.005"": {
""id"": ""TST002"",
""fullDescription"": ""description_005"",
""defaultLevel"": ""warning"",
""properties"": {
""isEnabledByDefault"": true
}
}
}
}
...
...
src/Compilers/Core/Portable/CommandLine/ErrorLogger.cs
浏览文件 @
50f8500d
...
...
@@ -317,7 +317,7 @@ private sealed class DiagnosticDescriptorSet
private
Dictionary
<
string
,
int
>
_counters
=
new
Dictionary
<
string
,
int
>();
// DiagnosticDescriptor -> unique key
private
Dictionary
<
DiagnosticDescriptor
,
string
>
_keys
=
new
Dictionary
<
DiagnosticDescriptor
,
string
>();
private
Dictionary
<
DiagnosticDescriptor
,
string
>
_keys
=
new
Dictionary
<
DiagnosticDescriptor
,
string
>(
new
Comparer
()
);
/// <summary>
/// The total number of descriptors in the set.
...
...
@@ -381,6 +381,54 @@ public string Add(DiagnosticDescriptor descriptor)
list
.
Sort
((
x
,
y
)
=>
string
.
CompareOrdinal
(
x
.
Key
,
y
.
Key
));
return
list
;
}
/// <summary>
/// Compares descriptors by the values that we write to the log and nothing else.
///
/// We cannot use the IEquatable implementation because it includes message format
/// and we don't write it out. It also ignores tags, which we do write.
/// </summary>
private
sealed
class
Comparer
:
IEqualityComparer
<
DiagnosticDescriptor
>
{
public
bool
Equals
(
DiagnosticDescriptor
x
,
DiagnosticDescriptor
y
)
{
if
(
ReferenceEquals
(
x
,
y
))
return
true
;
if
(
ReferenceEquals
(
x
,
null
)
||
ReferenceEquals
(
y
,
null
))
return
false
;
return
(
x
.
Category
==
y
.
Category
&&
x
.
DefaultSeverity
==
y
.
DefaultSeverity
&&
x
.
Description
.
Equals
(
y
.
Description
)
&&
x
.
HelpLinkUri
==
y
.
HelpLinkUri
&&
x
.
Id
==
y
.
Id
&&
x
.
IsEnabledByDefault
==
y
.
IsEnabledByDefault
&&
x
.
Title
.
Equals
(
y
.
Title
)
&&
x
.
CustomTags
.
SequenceEqual
(
y
.
CustomTags
));
}
public
int
GetHashCode
(
DiagnosticDescriptor
obj
)
{
if
(
ReferenceEquals
(
obj
,
null
))
return
0
;
int
hash
=
Hash
.
Combine
(
obj
.
Category
.
GetHashCode
(),
Hash
.
Combine
(
obj
.
DefaultSeverity
.
GetHashCode
(),
Hash
.
Combine
(
obj
.
Description
.
GetHashCode
(),
Hash
.
Combine
(
obj
.
HelpLinkUri
.
GetHashCode
(),
Hash
.
Combine
(
obj
.
Id
.
GetHashCode
(),
Hash
.
Combine
(
obj
.
IsEnabledByDefault
.
GetHashCode
(),
obj
.
Title
.
GetHashCode
()))))));
foreach
(
string
tag
in
obj
.
CustomTags
)
{
hash
=
Hash
.
Combine
(
tag
,
hash
);
}
return
hash
;
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录