Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
82de928e
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
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,发现更多精彩内容 >>
提交
82de928e
编写于
10月 08, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add comments and simplify code.
上级
fea33a0d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
14 deletion
+31
-14
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationDiagnosticAnalyzer.cs
...eDeclaration/CSharpInlineDeclarationDiagnosticAnalyzer.cs
+1
-2
src/Features/Core/Portable/CodeStyle/AbstractCodeStyleDiagnosticAnalyzer.cs
...Portable/CodeStyle/AbstractCodeStyleDiagnosticAnalyzer.cs
+27
-7
src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs
...ializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs
+2
-3
src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
...xpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
+1
-2
未找到文件。
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationDiagnosticAnalyzer.cs
浏览文件 @
82de928e
...
...
@@ -26,7 +26,6 @@ internal class CSharpInlineDeclarationDiagnosticAnalyzer : AbstractCodeStyleDiag
{
public
CSharpInlineDeclarationDiagnosticAnalyzer
()
:
base
(
IDEDiagnosticIds
.
InlineDeclarationDiagnosticId
,
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Inline_variable_declaration
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)),
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Inline_variable_declaration
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)))
{
}
...
...
@@ -197,7 +196,7 @@ private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
:
localDeclarator
;
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
CreateDescriptor
(
this
.
Id
,
option
.
Notification
.
Value
),
CreateDescriptor
(
this
.
Descriptor
Id
,
option
.
Notification
.
Value
),
reportNode
.
GetLocation
(),
additionalLocations
:
allLocations
));
}
...
...
src/Features/Core/Portable/CodeStyle/AbstractCodeStyleDiagnosticAnalyzer.cs
浏览文件 @
82de928e
...
...
@@ -7,23 +7,43 @@ namespace Microsoft.CodeAnalysis.CodeStyle
{
internal
abstract
class
AbstractCodeStyleDiagnosticAnalyzer
:
DiagnosticAnalyzer
{
protected
readonly
string
Id
;
protected
readonly
string
DescriptorId
;
/// <summary>
/// Diagnostic descriptor for code you want to fade out *and* want to have a smart-tag
/// appear for. This is the common descriptor for code that is being faded out
/// </summary>
protected
readonly
DiagnosticDescriptor
UnnecessaryWithSuggestionDescriptor
;
/// <summary>
/// Diagnostic descriptor for code you want to fade out and do *not* want to have a smart-tag
/// appear for. This is uncommon but useful in some cases. For example, if you are fading
/// out pieces of code before/after another piece of code *on the same line*, then you will
/// only want one usafe of <see cref="UnnecessaryWithSuggestionDescriptor"/> and multiple
/// usages of <see cref="UnnecessaryWithoutSuggestionDescriptor"/>.
///
/// That's because if you use <see cref="UnnecessaryWithSuggestionDescriptor"/> for all the
/// faded out code then that will mean the user will see multiple code actions to fix the
/// same issue when they bring up the code action on that line. Using these two descriptors
/// helps ensure that there will not be useless code-action overload.
/// </summary>
protected
readonly
DiagnosticDescriptor
UnnecessaryWithoutSuggestionDescriptor
;
private
readonly
LocalizableString
_localizableTitle
;
private
readonly
LocalizableString
_localizableMessage
;
private
readonly
DiagnosticDescriptor
_descriptor
;
protected
AbstractCodeStyleDiagnosticAnalyzer
(
string
id
,
LocalizableString
title
,
LocalizableString
message
)
protected
AbstractCodeStyleDiagnosticAnalyzer
(
string
descriptorId
,
LocalizableString
title
,
LocalizableString
message
=
null
)
{
Id
=
i
d
;
DescriptorId
=
descriptorI
d
;
_localizableTitle
=
title
;
_localizableMessage
=
message
;
_descriptor
=
CreateDescriptor
(
id
,
DiagnosticSeverity
.
Hidden
);
_localizableMessage
=
message
??
title
;
_descriptor
=
CreateDescriptor
(
descriptorId
,
DiagnosticSeverity
.
Hidden
);
UnnecessaryWithSuggestionDescriptor
=
CreateDescriptor
(
i
d
,
DiagnosticSeverity
.
Hidden
,
DiagnosticCustomTags
.
Unnecessary
);
UnnecessaryWithoutSuggestionDescriptor
=
CreateDescriptor
(
i
d
+
"WithoutSuggestion"
,
descriptorI
d
,
DiagnosticSeverity
.
Hidden
,
DiagnosticCustomTags
.
Unnecessary
);
UnnecessaryWithoutSuggestionDescriptor
=
CreateDescriptor
(
descriptorI
d
+
"WithoutSuggestion"
,
DiagnosticSeverity
.
Hidden
,
DiagnosticCustomTags
.
Unnecessary
);
SupportedDiagnostics
=
ImmutableArray
.
Create
(
_descriptor
,
UnnecessaryWithoutSuggestionDescriptor
,
UnnecessaryWithSuggestionDescriptor
);
...
...
src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs
浏览文件 @
82de928e
...
...
@@ -33,8 +33,7 @@ internal abstract class AbstractUseObjectInitializerDiagnosticAnalyzer<
protected
AbstractUseObjectInitializerDiagnosticAnalyzer
()
:
base
(
IDEDiagnosticIds
.
UseObjectInitializerDiagnosticId
,
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Object_initialization_can_be_simplified
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)),
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Object_initialization_can_be_simplified
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)))
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Object_initialization_can_be_simplified
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)))
{
}
...
...
@@ -72,7 +71,7 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
var
severity
=
option
.
Notification
.
Value
;
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
CreateDescriptor
(
Id
,
severity
),
CreateDescriptor
(
Descriptor
Id
,
severity
),
objectCreationExpression
.
GetLocation
(),
additionalLocations
:
locations
));
...
...
src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
浏览文件 @
82de928e
...
...
@@ -35,7 +35,6 @@ internal abstract class AbstractUseThrowExpressionDiagnosticAnalyzer : AbstractC
{
protected
AbstractUseThrowExpressionDiagnosticAnalyzer
()
:
base
(
IDEDiagnosticIds
.
UseThrowExpressionDiagnosticId
,
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Use_throw_expression
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)),
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Use_throw_expression
),
FeaturesResources
.
ResourceManager
,
typeof
(
FeaturesResources
)))
{
}
...
...
@@ -133,7 +132,7 @@ private void AnalyzeOperation(OperationAnalysisContext context)
throwOperation
.
ThrownObject
.
Syntax
.
GetLocation
(),
assignmentExpression
.
Value
.
Syntax
.
GetLocation
());
var
descriptor
=
CreateDescriptor
(
Id
,
option
.
Notification
.
Value
);
var
descriptor
=
CreateDescriptor
(
Descriptor
Id
,
option
.
Notification
.
Value
);
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
descriptor
,
throwStatement
.
GetLocation
(),
additionalLocations
:
allLocations
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录