Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ad0ff108
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,发现更多精彩内容 >>
提交
ad0ff108
编写于
4月 07, 2015
作者:
S
Srivatsn Narayanan
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1650 from srivatsn/fixtests
Unskip tests fixed by #662 and #679.
上级
c6e00fe1
9d1f094d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
137 addition
and
29 deletion
+137
-29
src/Diagnostics/FxCop/System.Runtime.Analyzers/Core/Design/DefineAccessorsForAttributeArguments.Fixer.cs
...Core/Design/DefineAccessorsForAttributeArguments.Fixer.cs
+31
-5
src/Diagnostics/FxCop/System.Runtime.Analyzers/Test/Design/DefineAccessorsForAttributeArgumentsTests.Fixer.cs
...Design/DefineAccessorsForAttributeArgumentsTests.Fixer.cs
+106
-24
未找到文件。
src/Diagnostics/FxCop/System.Runtime.Analyzers/Core/Design/DefineAccessorsForAttributeArguments.Fixer.cs
浏览文件 @
ad0ff108
...
...
@@ -40,9 +40,13 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
return
;
case
DefineAccessorsForAttributeArgumentsAnalyzer
.
MakePublicCase
:
context
.
RegisterCodeFix
(
new
MyCodeAction
(
SystemRuntimeAnalyzersResources
.
MakeGetterPublic
,
async
ct
=>
await
MakePublic
(
context
.
Document
,
node
,
ct
).
ConfigureAwait
(
false
)),
diagnostic
);
var
property
=
generator
.
GetDeclaration
(
node
,
DeclarationKind
.
Property
);
if
(
property
!=
null
)
{
context
.
RegisterCodeFix
(
new
MyCodeAction
(
SystemRuntimeAnalyzersResources
.
MakeGetterPublic
,
async
ct
=>
await
MakePublic
(
context
.
Document
,
node
,
property
,
ct
).
ConfigureAwait
(
false
)),
diagnostic
);
}
return
;
case
DefineAccessorsForAttributeArgumentsAnalyzer
.
RemoveSetterCase
:
...
...
@@ -96,6 +100,7 @@ private async Task<Document> AddAccessor(Document document, SyntaxNode parameter
(
editor
,
propertyDeclaration
)
=>
{
editor
.
SetGetAccessorStatements
(
propertyDeclaration
,
null
);
editor
.
SetModifiers
(
propertyDeclaration
,
editor
.
Generator
.
GetModifiers
(
propertyDeclaration
)
-
DeclarationModifiers
.
WriteOnly
);
},
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
@@ -103,10 +108,31 @@ private async Task<Document> AddAccessor(Document document, SyntaxNode parameter
return
symbolEditor
.
GetChangedDocuments
().
First
();
}
private
async
Task
<
Document
>
MakePublic
(
Document
document
,
SyntaxNode
getMethod
,
CancellationToken
cancellationToken
)
private
async
Task
<
Document
>
MakePublic
(
Document
document
,
SyntaxNode
getMethod
,
SyntaxNode
property
,
CancellationToken
cancellationToken
)
{
// Clear the accessibility on the getter.
DocumentEditor
editor
=
await
DocumentEditor
.
CreateAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
editor
.
SetAccessibility
(
getMethod
,
Accessibility
.
Public
);
editor
.
SetAccessibility
(
getMethod
,
Accessibility
.
NotApplicable
);
// If the containing property is not public, make it so
var
propertyAccessibility
=
editor
.
Generator
.
GetAccessibility
(
property
);
if
(
propertyAccessibility
!=
Accessibility
.
Public
)
{
editor
.
SetAccessibility
(
property
,
Accessibility
.
Public
);
// Having just made the property public, if it has a setter with no accesibility set, then we've just made the setter public.
// Instead restore the setter's original accessibility so that we don't fire a violation with the generated code.
var
setter
=
editor
.
Generator
.
GetAccessor
(
property
,
DeclarationKind
.
SetAccessor
);
if
(
setter
!=
null
)
{
var
setterAccesibility
=
editor
.
Generator
.
GetAccessibility
(
setter
);
if
(
setterAccesibility
==
Accessibility
.
NotApplicable
)
{
editor
.
SetAccessibility
(
setter
,
propertyAccessibility
);
}
}
}
return
editor
.
GetChangedDocument
();
}
...
...
src/Diagnostics/FxCop/System.Runtime.Analyzers/Test/Design/DefineAccessorsForAttributeArgumentsTests.Fixer.cs
浏览文件 @
ad0ff108
...
...
@@ -94,7 +94,7 @@ public string Name
}"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
CSharp_CA1019_MakeGetterPublic
()
{
VerifyCSharpFix
(
@"
...
...
@@ -113,7 +113,7 @@ public InternalGetterTestAttribute(string name)
public string Name
{
internal get { return m_name; }
set { m_name = value; }
internal
set { m_name = value; }
}
}"
,
@"
using System;
...
...
@@ -131,12 +131,12 @@ public InternalGetterTestAttribute(string name)
public string Name
{
get { return m_name; }
set { m_name = value; }
internal
set { m_name = value; }
}
}"
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
CSharp_CA1019_MakeGetterPublic2
()
{
VerifyCSharpFix
(
@"
...
...
@@ -173,12 +173,53 @@ public InternalGetterTestAttribute(string name)
public string Name
{
get { return m_name; }
set { m_name = value; }
internal set { m_name = value; }
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
CSharp_CA1019_MakeGetterPublic3
()
{
VerifyCSharpFix
(
@"
using System;
[AttributeUsage(AttributeTargets.All)]
public sealed class InternalGetterTestAttribute : Attribute
{
private string m_name;
public InternalGetterTestAttribute(string name)
{
m_name = name;
}
internal string Name
{
get { return m_name; }
}
}"
,
@"
using System;
[AttributeUsage(AttributeTargets.All)]
public sealed class InternalGetterTestAttribute : Attribute
{
private string m_name;
public InternalGetterTestAttribute(string name)
{
m_name = name;
}
public string Name
{
get { return m_name; }
}
}"
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
CSharp_CA1019_MakeSetterInternal
()
{
VerifyCSharpFix
(
@"
...
...
@@ -215,6 +256,7 @@ public PublicSetterTestAttribute(string name)
public string Name
{
get { return m_name; }
internal set { m_name = value; }
}
}"
);
...
...
@@ -253,7 +295,7 @@ End Property
End Class"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/679"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
VisualBasic_CA1019_AddAccessor2
()
{
VerifyBasicFix
(
@"
...
...
@@ -267,9 +309,9 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public WriteOnly Property Name() As String
Set
Friend
Set
m_name = value
End Set
End Property
...
...
@@ -284,9 +326,9 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Set
Friend
Set
m_name = value
End Set
Get
...
...
@@ -295,7 +337,7 @@ End Property
End Class"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
VisualBasic_CA1019_MakeGetterPublic
()
{
VerifyBasicFix
(
@"
...
...
@@ -309,12 +351,12 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Friend Get
Return m_name
End Get
Set
Friend
Set
m_name = value
End Set
End Property
...
...
@@ -329,19 +371,19 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Get
Return m_name
End Get
Set
Friend
Set
m_name = value
End Set
End Property
End Class"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
VisualBasic_CA1019_MakeGetterPublic2
()
{
VerifyBasicFix
(
@"
...
...
@@ -355,7 +397,7 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Friend Property Name() As String
Get
Return m_name
...
...
@@ -375,19 +417,59 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Get
Return m_name
End Get
Set
Friend
Set
m_name = value
End Set
End Property
End Class"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/662"
),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
VisualBasic_CA1019_MakeGetterPublic3
()
{
VerifyBasicFix
(
@"
Imports System
<AttributeUsage(AttributeTargets.All)> _
Public NotInheritable Class InternalGetterTestAttribute
Inherits Attribute
Private m_name As String
Public Sub New(name As String)
m_name = name
End Sub
Friend Property Name() As String
Get
Return m_name
End Get
End Property
End Class"
,
@"
Imports System
<AttributeUsage(AttributeTargets.All)> _
Public NotInheritable Class InternalGetterTestAttribute
Inherits Attribute
Private m_name As String
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Get
Return m_name
End Get
End Property
End Class"
,
allowNewCompilerDiagnostics
:
true
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
VisualBasic_CA1019_MakeSetterInternal
()
{
VerifyBasicFix
(
@"
...
...
@@ -401,8 +483,8 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Property Name() As String
P
ublic P
roperty Name() As String
Get
Return m_name
End Get
...
...
@@ -421,7 +503,7 @@ Inherits Attribute
Public Sub New(name As String)
m_name = name
End Sub
Public Property Name() As String
Get
Return m_name
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录