Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
09bd524a
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,发现更多精彩内容 >>
提交
09bd524a
编写于
12月 30, 2019
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review feedback.
上级
068d21ad
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
17 deletion
+30
-17
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
...entation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
+1
-1
src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs
...on/Diagnostics/DiagnosticsClassificationTaggerProvider.cs
+15
-11
src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs
src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs
+13
-3
src/Features/Core/Portable/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs
...AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs
+0
-1
src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
+1
-1
未找到文件。
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
浏览文件 @
09bd524a
...
...
@@ -110,7 +110,7 @@ protected override ITaggerEventSource CreateEventSource(ITextView textViewOpt, I
/// <summary>
/// Get the <see cref="DiagnosticDataLocation"/> that should have the tag applied to it.
/// In most cases, this is the <see cref="DiagnosticData.DataLocation"/> but overrides (e.g. unnecessary classifications).
/// In most cases, this is the <see cref="DiagnosticData.DataLocation"/> but overrides
can change it
(e.g. unnecessary classifications).
/// </summary>
/// <param name="diagnosticData">the diagnostic containing the location(s).</param>
/// <returns>an array of locations that should have the tag applied.</returns>
...
...
src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs
浏览文件 @
09bd524a
...
...
@@ -11,16 +11,15 @@
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Editor.Shared.Options
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Shared.Options
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Tagging
;
using
Microsoft.VisualStudio.Utilities
;
using
Newtonsoft.Json
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics
...
...
@@ -67,11 +66,11 @@ internal partial class DiagnosticsClassificationTaggerProvider : AbstractDiagnos
protected
internal
override
ImmutableArray
<
DiagnosticDataLocation
>
GetLocationsToTag
(
DiagnosticData
diagnosticData
)
{
using
var
locationsToTagDisposer
=
ArrayBuilder
<
DiagnosticDataLocation
>.
GetInstance
(
out
var
locationsToTag
);
using
var
locationsToTagDisposer
=
PooledObjects
.
ArrayBuilder
<
DiagnosticDataLocation
>.
GetInstance
(
out
var
locationsToTag
);
// If there are 'unnecessary' locations specified in the property bag, use those instead of the main diagnostic location.
if
(
diagnosticData
.
AdditionalLocations
!=
null
&&
diagnosticData
.
AdditionalLocations
.
Count
>
0
if
(
diagnosticData
.
AdditionalLocations
?.
Count
>
0
&&
diagnosticData
.
Properties
!=
null
&&
diagnosticData
.
Properties
.
TryGetValue
(
WellKnownDiagnosticTags
.
Unnecessary
,
out
var
unnecessaryIndices
))
{
var
additionalLocations
=
diagnosticData
.
AdditionalLocations
.
ToImmutableArray
();
...
...
@@ -87,12 +86,17 @@ protected internal override ImmutableArray<DiagnosticDataLocation> GetLocationsT
static
IEnumerable
<
int
>
GetLocationIndices
(
string
indicesProperty
)
{
var
stream
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
indicesProperty
));
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
IEnumerable
<
int
>));
var
result
=
serializer
.
ReadObject
(
stream
)
as
IEnumerable
<
int
>;
stream
.
Close
();
return
result
;
try
{
using
var
stream
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
indicesProperty
));
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
IEnumerable
<
int
>));
var
result
=
serializer
.
ReadObject
(
stream
)
as
IEnumerable
<
int
>;
return
result
;
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportWithoutCrash
(
e
))
{
return
ImmutableArray
<
int
>.
Empty
;
}
}
}
}
...
...
src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs
浏览文件 @
09bd524a
...
...
@@ -8,6 +8,7 @@
using
System.Runtime.Serialization.Json
;
using
System.Text
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Diagnostics
...
...
@@ -69,7 +70,10 @@ internal static class DiagnosticHelper
/// Typically, these are locations of other items referenced in the message.
/// If null, <see cref="Diagnostic.AdditionalLocations"/> will return an empty list.
/// </param>
/// <param name="tagIndices">a map of location tag to index in additional locations.</param>
/// <param name="tagIndices">
/// a map of location tag to index in additional locations.
/// <see cref="AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer{TLanguageKindEnum, TParenthesizedExpressionSyntax}"/> for an example of usage.
/// </param>
/// <param name="messageArgs">Arguments to the message of the diagnostic.</param>
/// <returns>The <see cref="Diagnostic"/> instance.</returns>
public
static
Diagnostic
CreateWithLocationTags
(
...
...
@@ -80,12 +84,18 @@ internal static class DiagnosticHelper
IDictionary
<
string
,
IEnumerable
<
int
>>
tagIndices
,
params
object
[]
messageArgs
)
{
var
properties
=
tagIndices
.
Select
(
kvp
=>
new
KeyValuePair
<
string
,
string
>(
kvp
.
Key
,
EncodeIndices
(
kvp
.
Value
))).
ToImmutableDictionary
();
Contract
.
ThrowIfTrue
(
additionalLocations
.
IsEmpty
());
Contract
.
ThrowIfTrue
(
tagIndices
.
IsEmpty
());
var
properties
=
tagIndices
.
Select
(
kvp
=>
new
KeyValuePair
<
string
,
string
>(
kvp
.
Key
,
EncodeIndices
(
kvp
.
Value
,
additionalLocations
.
Count
()))).
ToImmutableDictionary
();
return
Create
(
descriptor
,
location
,
effectiveSeverity
,
additionalLocations
,
properties
,
messageArgs
);
static
string
EncodeIndices
(
IEnumerable
<
int
>
indices
)
static
string
EncodeIndices
(
IEnumerable
<
int
>
indices
,
int
additionalLocationsLength
)
{
// Ensure that the provided tag index is a valid index into additional locations.
Contract
.
ThrowIfFalse
(
indices
.
All
(
idx
=>
idx
>=
0
&&
idx
<
additionalLocationsLength
));
using
var
stream
=
new
MemoryStream
();
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
IEnumerable
<
int
>));
serializer
.
WriteObject
(
stream
,
indices
);
...
...
src/Features/Core/Portable/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs
浏览文件 @
09bd524a
...
...
@@ -5,7 +5,6 @@
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Threading
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CodeStyle
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.LanguageServices
;
...
...
src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
浏览文件 @
09bd524a
...
...
@@ -34,7 +34,7 @@ internal sealed class DiagnosticData : IEquatable<DiagnosticData>
public
readonly
ProjectId
?
ProjectId
;
public
readonly
DiagnosticDataLocation
?
DataLocation
;
public
readonly
IReadOnlyCollection
<
DiagnosticDataLocation
>
?
AdditionalLocations
;
public
readonly
IReadOnlyCollection
<
DiagnosticDataLocation
>
AdditionalLocations
;
/// <summary>
/// Language name (<see cref="LanguageNames"/>) or null if the diagnostic is not associated with source code.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录