📄 attributesuffixisattributerule.cs
字号:
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krueger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Reflection;
namespace ICSharpCode.AssemblyAnalyser.Rules
{
/// <summary>
/// Description of AttributeSuffixIsAttribute.
/// </summary>
public class AttributeSuffixIsAttributeRule : AbstractReflectionRule, ITypeRule
{
public override string Description {
get {
return "${res:ICSharpCode.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Description}";
}
}
public override string Details {
get {
return "${res:ICSharpCode.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Details}";
}
}
public Resolution Check(Type type)
{
if (type.IsSubclassOf(typeof(System.Attribute)) && !type.Name.EndsWith("Attribute")) {
return new Resolution(this, "${res:ICSharpCode.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
}
return null;
}
}
}
#region Unit Test
#if TEST
namespace ICSharpCode.AssemblyAnalyser.Rules
{
using NUnit.Framework;
[TestFixture]
public class AttributeSuffixIsAttributeRuleTest
{
class MyAttribute : System.Attribute
{
}
[Test]
public void TestCorrectAttribute()
{
AttributeSuffixIsAttributeRule rule = new AttributeSuffixIsAttributeRule();
Assertion.AssertNull(rule.Check(typeof(MyAttribute)));
}
class MyAttr : System.Attribute
{
}
[Test]
public void TestIncorrectAttribute()
{
AttributeSuffixIsAttributeRule rule = new AttributeSuffixIsAttributeRule();
Assertion.AssertNotNull(rule.Check(typeof(MyAttr)));
}
}
}
#endif
#endregion
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -