Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4bc5bcb7
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,发现更多精彩内容 >>
提交
4bc5bcb7
编写于
3月 31, 2019
作者:
Y
yair halberstadt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deal correctly with an obsolete inherited set method on an attribute
上级
921240d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
2 deletion
+91
-2
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
+3
-2
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
...est/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
+88
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
浏览文件 @
4bc5bcb7
...
@@ -356,9 +356,10 @@ private BoundExpression BindNamedAttributeArgument(AttributeArgumentSyntax named
...
@@ -356,9 +356,10 @@ private BoundExpression BindNamedAttributeArgument(AttributeArgumentSyntax named
if
(
namedArgumentNameSymbol
.
Kind
==
SymbolKind
.
Property
)
if
(
namedArgumentNameSymbol
.
Kind
==
SymbolKind
.
Property
)
{
{
var
propertySymbol
=
(
PropertySymbol
)
namedArgumentNameSymbol
;
var
propertySymbol
=
(
PropertySymbol
)
namedArgumentNameSymbol
;
if
(
propertySymbol
.
SetMethod
!=
null
)
var
setMethod
=
propertySymbol
.
GetOwnOrInheritedSetMethod
();
if
(
setMethod
!=
null
)
{
{
ReportDiagnosticsIfObsolete
(
diagnostics
,
propertySymbol
.
S
etMethod
,
namedArgument
,
hasBaseReceiver
:
false
);
ReportDiagnosticsIfObsolete
(
diagnostics
,
s
etMethod
,
namedArgument
,
hasBaseReceiver
:
false
);
}
}
}
}
...
...
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
浏览文件 @
4bc5bcb7
...
@@ -6696,6 +6696,94 @@ public class Test
...
@@ -6696,6 +6696,94 @@ public class Test
Diagnostic
(
ErrorCode
.
ERR_DeprecatedSymbolStr
,
"Att()"
).
WithArguments
(
"Att.Att()"
,
"Constructor"
).
WithLocation
(
46
,
6
));
Diagnostic
(
ErrorCode
.
ERR_DeprecatedSymbolStr
,
"Att()"
).
WithArguments
(
"Att.Att()"
,
"Constructor"
).
WithLocation
(
46
,
6
));
}
}
[
Fact
]
public
void
TestOverridenObsoleteSetterOnAttributes
()
{
var
source
=
@"
using System;
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class BaseAtt : Attribute
{
public virtual int Prop
{
get { return 1; }
[Obsolete(""setter"", true)] set { }
}
public virtual int Prop1
{
get { return 1; }
[Obsolete(""setter"", true)] set { }
}
public virtual int Prop2
{
get { return 1; }
[Obsolete(""base setter"", true)] set { }
}
public virtual int Prop3
{
get { return 1; }
set { }
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class DerivedAtt : BaseAtt
{
public override int Prop
{
get { return 1; }
}
public override int Prop1
{
get { return 1; }
set { }
}
public override int Prop2
{
get { return 1; }
[Obsolete(""derived setter"", true)] set { }
}
public override int Prop3
{
get { return 1; }
[Obsolete(""setter"", true)] set { }
}
}
[DerivedAtt(Prop = 1)]
[DerivedAtt(Prop1 = 1)]
[DerivedAtt(Prop2 = 1)]
[DerivedAtt(Prop3 = 1)]
public class Test
{
public static void Main() { }
}
"
;
CreateCompilation
(
source
).
VerifyDiagnostics
(
// (43,9): warning CS0672: Member 'DerivedAtt.Prop1.set' overrides obsolete member 'BaseAtt.Prop1.set'. Add the Obsolete attribute to 'DerivedAtt.Prop1.set'.
// set { }
Diagnostic
(
ErrorCode
.
WRN_NonObsoleteOverridingObsolete
,
"set"
).
WithArguments
(
"DerivedAtt.Prop1.set"
,
"BaseAtt.Prop1.set"
).
WithLocation
(
43
,
9
),
// (55,36): warning CS0809: Obsolete member 'DerivedAtt.Prop3.set' overrides non-obsolete member 'BaseAtt.Prop3.set'
// [Obsolete("setter", true)] set { }
Diagnostic
(
ErrorCode
.
WRN_ObsoleteOverridingNonObsolete
,
"set"
).
WithArguments
(
"DerivedAtt.Prop3.set"
,
"BaseAtt.Prop3.set"
).
WithLocation
(
55
,
36
),
// (59,13): error CS0619: 'BaseAtt.Prop.set' is obsolete: 'setter'
// [DerivedAtt(Prop = 1)]
Diagnostic
(
ErrorCode
.
ERR_DeprecatedSymbolStr
,
"Prop = 1"
).
WithArguments
(
"BaseAtt.Prop.set"
,
"setter"
).
WithLocation
(
59
,
13
),
// (60,13): error CS0619: 'BaseAtt.Prop1.set' is obsolete: 'setter'
// [DerivedAtt(Prop1 = 1)]
Diagnostic
(
ErrorCode
.
ERR_DeprecatedSymbolStr
,
"Prop1 = 1"
).
WithArguments
(
"BaseAtt.Prop1.set"
,
"setter"
).
WithLocation
(
60
,
13
),
// (61,13): error CS0619: 'BaseAtt.Prop2.set' is obsolete: 'base setter'
// [DerivedAtt(Prop2 = 1)]
Diagnostic
(
ErrorCode
.
ERR_DeprecatedSymbolStr
,
"Prop2 = 1"
).
WithArguments
(
"BaseAtt.Prop2.set"
,
"base setter"
).
WithLocation
(
61
,
13
));
}
[
Fact
]
[
Fact
]
public
void
TestObsoleteAttributeOnIndexerAccessors
()
public
void
TestObsoleteAttributeOnIndexerAccessors
()
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录