Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
903dd371
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,发现更多精彩内容 >>
提交
903dd371
编写于
7月 31, 2019
作者:
J
jnm2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Recognize existing GlobalSuppressions.cs having using directive
上级
9e275d45
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
17 deletion
+32
-17
src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb
...sualBasicTest/Diagnostics/Suppression/SuppressionTests.vb
+12
-12
src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
...CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
+10
-2
src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs
...odeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs
+3
-2
src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs
...deFixes/Suppression/AbstractSuppressionCodeFixProvider.cs
+1
-0
src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb
...ixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb
+6
-1
未找到文件。
src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb
浏览文件 @
903dd371
...
@@ -1475,7 +1475,7 @@ End Class]]>
...
@@ -1475,7 +1475,7 @@ End Class]]>
' a specific target and scoped to a namespace, type, member, etc.
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
<Pending>
""
, Scope:=
""
type
""
, Target:=
""
Class1
""
)>
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
<Pending>
""
, Scope:=
""
type
""
, Target:=
""
Class1
""
)>
<Assembly:
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
"
"
Await
TestAsync
(
source
.
ToString
(),
expected
)
Await
TestAsync
(
source
.
ToString
(),
expected
)
...
@@ -1511,7 +1511,7 @@ End Class
...
@@ -1511,7 +1511,7 @@ End Class
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
' a specific target and scoped to a namespace, type, member, etc.
<Assembly:
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
"
"
Await
TestAsync
(
source
.
ToString
(),
expected
)
Await
TestAsync
(
source
.
ToString
(),
expected
)
...
@@ -1557,7 +1557,7 @@ End Class
...
@@ -1557,7 +1557,7 @@ End Class
' a specific target and scoped to a namespace, type, member, etc.
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
<Pending>
""
, Scope:=
""
type
""
, Target:=
""
Class1
""
)>
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
<Pending>
""
, Scope:=
""
type
""
, Target:=
""
Class1
""
)>
<Assembly:
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
, Scope:=
""
type
""
, Target:=
""
~T:Class2
""
)>
"
"
Await
TestAsync
(
source
.
ToString
(),
expected
)
Await
TestAsync
(
source
.
ToString
(),
expected
)
...
@@ -1678,7 +1678,7 @@ End Class
...
@@ -1678,7 +1678,7 @@ End Class
Imports System
Imports System
' Some Trivia
' Some Trivia
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1701,7 +1701,7 @@ End Class
...
@@ -1701,7 +1701,7 @@ End Class
Imports
System
Imports
System
' Some Trivia
' Some Trivia
<
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"SomeOtherDiagnostic"
,
"SomeOtherDiagnostic:Title"
,
Justification
:
=
"<Pending>"
)
>
<
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"SomeOtherDiagnostic"
,
"SomeOtherDiagnostic:Title"
,
Justification
:
=
"<Pending>"
)
>
[|
Class
C
|]
[|
Class
C
|]
Sub
Method
()
Sub
Method
()
Dim
x
Dim
x
...
@@ -1712,8 +1712,8 @@ End Class
...
@@ -1712,8 +1712,8 @@ End Class
Imports System
Imports System
' Some Trivia
' Some Trivia
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
SomeOtherDiagnostic
""
,
""
SomeOtherDiagnostic:Title
""
, Justification:=
""
<Pending>
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
SomeOtherDiagnostic
""
,
""
SomeOtherDiagnostic:Title
""
, Justification:=
""
<Pending>
""
)>
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1752,7 +1752,7 @@ Imports System
...
@@ -1752,7 +1752,7 @@ Imports System
''' <summary>
''' <summary>
''' My custom type
''' My custom type
''' </summary>
''' </summary>
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1793,7 +1793,7 @@ Imports System
...
@@ -1793,7 +1793,7 @@ Imports System
''' My custom type
''' My custom type
''' </summary>
''' </summary>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
SomeOtherDiagnostic
""
,
""
SomeOtherDiagnostic:Title
""
, Justification:=
""
<Pending>
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
SomeOtherDiagnostic
""
,
""
SomeOtherDiagnostic:Title
""
, Justification:=
""
<Pending>
""
)>
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1827,7 +1827,7 @@ Imports System
...
@@ -1827,7 +1827,7 @@ Imports System
Namespace N
Namespace N
' Some Trivia
' Some Trivia
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1861,7 +1861,7 @@ Imports System
...
@@ -1861,7 +1861,7 @@ Imports System
Class Generic(Of T)
Class Generic(Of T)
' Some Trivia
' Some Trivia
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Class C
Class C
Sub Method()
Sub Method()
Dim x
Dim x
...
@@ -1896,7 +1896,7 @@ Imports System
...
@@ -1896,7 +1896,7 @@ Imports System
Class Generic(Of T)
Class Generic(Of T)
Class C
Class C
' Some Trivia
' Some Trivia
<
System.
Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
<Diagnostics.CodeAnalysis.SuppressMessage(
""
InfoDiagnostic
""
,
""
InfoDiagnostic:InfoDiagnostic
""
, Justification:=
""
{FeaturesResources.Pending}
""
)>
Sub Method()
Sub Method()
Dim x
Dim x
End Sub
End Sub
...
...
src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
浏览文件 @
903dd371
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Formatting
;
using
Microsoft.CodeAnalysis.Formatting
;
using
Microsoft.CodeAnalysis.Simplification
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Text
;
namespace
Microsoft.CodeAnalysis.CSharp.CodeFixes.Suppression
namespace
Microsoft.CodeAnalysis.CSharp.CodeFixes.Suppression
...
@@ -70,6 +71,11 @@ protected override SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnosti
...
@@ -70,6 +71,11 @@ protected override SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnosti
protected
override
string
SingleLineCommentStart
=>
"//"
;
protected
override
string
SingleLineCommentStart
=>
"//"
;
protected
override
bool
IsImportsLine
(
SyntaxNode
node
)
{
return
node
is
UsingDirectiveSyntax
;
}
protected
override
bool
IsAttributeListWithAssemblyAttributes
(
SyntaxNode
node
)
protected
override
bool
IsAttributeListWithAssemblyAttributes
(
SyntaxNode
node
)
{
{
return
node
is
AttributeListSyntax
attributeList
&&
return
node
is
AttributeListSyntax
attributeList
&&
...
@@ -124,9 +130,11 @@ protected override SyntaxNode AddLocalSuppressMessageAttribute(SyntaxNode target
...
@@ -124,9 +130,11 @@ protected override SyntaxNode AddLocalSuppressMessageAttribute(SyntaxNode target
SyntaxTriviaList
leadingTrivia
,
SyntaxTriviaList
leadingTrivia
,
bool
needsLeadingEndOfLine
)
bool
needsLeadingEndOfLine
)
{
{
var
attributeName
=
SyntaxFactory
.
ParseName
(
SuppressMessageAttributeName
).
WithAdditionalAnnotations
(
Simplifier
.
Annotation
);
var
attributeArguments
=
CreateAttributeArguments
(
targetSymbol
,
diagnostic
,
isAssemblyAttribute
);
var
attributeArguments
=
CreateAttributeArguments
(
targetSymbol
,
diagnostic
,
isAssemblyAttribute
);
var
attribute
=
SyntaxFactory
.
Attribute
(
SyntaxFactory
.
ParseName
(
SuppressMessageAttributeName
),
attributeArguments
);
var
attributes
=
new
SeparatedSyntaxList
<
AttributeSyntax
>().
Add
(
attribute
);
var
attributes
=
new
SeparatedSyntaxList
<
AttributeSyntax
>()
.
Add
(
SyntaxFactory
.
Attribute
(
attributeName
,
attributeArguments
));
AttributeListSyntax
attributeList
;
AttributeListSyntax
attributeList
;
if
(
isAssemblyAttribute
)
if
(
isAssemblyAttribute
)
...
...
src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs
浏览文件 @
903dd371
...
@@ -70,12 +70,13 @@ protected async Task<Document> GetOrCreateSuppressionsDocumentAsync(Cancellation
...
@@ -70,12 +70,13 @@ protected async Task<Document> GetOrCreateSuppressionsDocumentAsync(Cancellation
var
fullPath
=
!
string
.
IsNullOrEmpty
(
filePath
)
?
Path
.
GetFullPath
(
filePath
)
:
filePath
;
var
fullPath
=
!
string
.
IsNullOrEmpty
(
filePath
)
?
Path
.
GetFullPath
(
filePath
)
:
filePath
;
if
(
fullPath
==
suppressionsFilePath
)
if
(
fullPath
==
suppressionsFilePath
)
{
{
// Existing global suppressions file, see if this file only has global assembly attributes.
// Existing global suppressions file. See if this file only has imports and global assembly
// attributes.
hasDocWithSuppressionsName
=
true
;
hasDocWithSuppressionsName
=
true
;
var
t
=
await
document
.
GetSyntaxTreeAsync
(
c
).
ConfigureAwait
(
false
);
var
t
=
await
document
.
GetSyntaxTreeAsync
(
c
).
ConfigureAwait
(
false
);
var
r
=
await
t
.
GetRootAsync
(
c
).
ConfigureAwait
(
false
);
var
r
=
await
t
.
GetRootAsync
(
c
).
ConfigureAwait
(
false
);
if
(
r
.
ChildNodes
().
All
(
n
=>
Fixer
.
IsAttributeListWithAssemblyAttributes
(
n
)))
if
(
r
.
ChildNodes
().
All
(
n
=>
Fixer
.
Is
ImportsLine
(
n
)
||
Fixer
.
Is
AttributeListWithAssemblyAttributes
(
n
)))
{
{
suppressionsDoc
=
document
;
suppressionsDoc
=
document
;
break
;
break
;
...
...
src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs
浏览文件 @
903dd371
...
@@ -49,6 +49,7 @@ public bool IsFixableDiagnostic(Diagnostic diagnostic)
...
@@ -49,6 +49,7 @@ public bool IsFixableDiagnostic(Diagnostic diagnostic)
protected
abstract
string
DefaultFileExtension
{
get
;
}
protected
abstract
string
DefaultFileExtension
{
get
;
}
protected
abstract
string
SingleLineCommentStart
{
get
;
}
protected
abstract
string
SingleLineCommentStart
{
get
;
}
protected
abstract
bool
IsImportsLine
(
SyntaxNode
node
);
protected
abstract
bool
IsAttributeListWithAssemblyAttributes
(
SyntaxNode
node
);
protected
abstract
bool
IsAttributeListWithAssemblyAttributes
(
SyntaxNode
node
);
protected
abstract
bool
IsEndOfLine
(
SyntaxTrivia
trivia
);
protected
abstract
bool
IsEndOfLine
(
SyntaxTrivia
trivia
);
protected
abstract
bool
IsEndOfFileToken
(
SyntaxToken
token
);
protected
abstract
bool
IsEndOfFileToken
(
SyntaxToken
token
);
...
...
src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb
浏览文件 @
903dd371
...
@@ -6,6 +6,7 @@ Imports System.Threading
...
@@ -6,6 +6,7 @@ Imports System.Threading
Imports
Microsoft.CodeAnalysis.CodeFixes
Imports
Microsoft.CodeAnalysis.CodeFixes
Imports
Microsoft.CodeAnalysis.CodeFixes.Suppression
Imports
Microsoft.CodeAnalysis.CodeFixes.Suppression
Imports
Microsoft.CodeAnalysis.Formatting
Imports
Microsoft.CodeAnalysis.Formatting
Imports
Microsoft.CodeAnalysis.Simplification
Imports
Microsoft.CodeAnalysis.Text
Imports
Microsoft.CodeAnalysis.Text
Imports
Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports
Microsoft.CodeAnalysis.VisualBasic.Syntax
...
@@ -109,6 +110,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Suppression
...
@@ -109,6 +110,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Suppression
End
Get
End
Get
End
Property
End
Property
Protected
Overrides
Function
IsImportsLine
(
node
As
SyntaxNode
)
As
Boolean
Return
TypeOf
node
Is
ImportsStatementSyntax
End
Function
Protected
Overrides
Function
IsAttributeListWithAssemblyAttributes
(
node
As
SyntaxNode
)
As
Boolean
Protected
Overrides
Function
IsAttributeListWithAssemblyAttributes
(
node
As
SyntaxNode
)
As
Boolean
Dim
attributesStatement
=
TryCast
(
node
,
AttributesStatementSyntax
)
Dim
attributesStatement
=
TryCast
(
node
,
AttributesStatementSyntax
)
Return
attributesStatement
IsNot
Nothing
AndAlso
Return
attributesStatement
IsNot
Nothing
AndAlso
...
@@ -158,7 +163,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Suppression
...
@@ -158,7 +163,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Suppression
Private
Function
CreateAttributeList
(
targetSymbol
As
ISymbol
,
diagnostic
As
Diagnostic
,
isAssemblyAttribute
As
Boolean
)
As
AttributeListSyntax
Private
Function
CreateAttributeList
(
targetSymbol
As
ISymbol
,
diagnostic
As
Diagnostic
,
isAssemblyAttribute
As
Boolean
)
As
AttributeListSyntax
Dim
attributeTarget
=
If
(
isAssemblyAttribute
,
SyntaxFactory
.
AttributeTarget
(
SyntaxFactory
.
Token
(
SyntaxKind
.
AssemblyKeyword
)),
Nothing
)
Dim
attributeTarget
=
If
(
isAssemblyAttribute
,
SyntaxFactory
.
AttributeTarget
(
SyntaxFactory
.
Token
(
SyntaxKind
.
AssemblyKeyword
)),
Nothing
)
Dim
attributeName
=
SyntaxFactory
.
ParseName
(
SuppressMessageAttributeName
)
Dim
attributeName
=
SyntaxFactory
.
ParseName
(
SuppressMessageAttributeName
)
.
WithAdditionalAnnotations
(
Simplifier
.
Annotation
)
Dim
attributeArguments
=
CreateAttributeArguments
(
targetSymbol
,
diagnostic
,
isAssemblyAttribute
)
Dim
attributeArguments
=
CreateAttributeArguments
(
targetSymbol
,
diagnostic
,
isAssemblyAttribute
)
Dim
attribute
As
AttributeSyntax
=
SyntaxFactory
.
Attribute
(
attributeTarget
,
attributeName
,
attributeArguments
)
Dim
attribute
As
AttributeSyntax
=
SyntaxFactory
.
Attribute
(
attributeTarget
,
attributeName
,
attributeArguments
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录