本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol.GetAttributes方法的具体用法?C# MethodSymbol.GetAttributes怎么用?C# MethodSymbol.GetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol
的用法示例。
在下文中一共展示了MethodSymbol.GetAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAttributePropagation
private static string CheckAttributePropagation(MethodSymbol moveNext)
{
string result = "";
if (moveNext.GetAttributes("", "MyAttribute").Any())
{
result += "MyAttribute is present\n";
}
if (!moveNext.GetAttributes("System.Diagnostics", "DebuggerNonUserCodeAttribute").Any())
{
result += "DebuggerNonUserCodeAttribute is missing\n";
}
if (!moveNext.GetAttributes("System.Diagnostics", "DebuggerHiddenAttribute").Any())
{
result += "DebuggerHiddenAttribute is missing\n";
}
if (!moveNext.GetAttributes("System.Diagnostics", "DebuggerStepperBoundaryAttribute").Any())
{
result += "DebuggerStepperBoundaryAttribute is missing\n";
}
if (!moveNext.GetAttributes("System.Diagnostics", "DebuggerStepThroughAttribute").Any())
{
result += "DebuggerStepThroughAttribute is missing\n";
}
return result;
}
示例2: TestAttributeOnPartialMethodHelper
private void TestAttributeOnPartialMethodHelper(ModuleSymbol m, MethodSymbol fooMethod)
{
var a1Class = m.GlobalNamespace.GetTypeMember("A1");
var a2Class = m.GlobalNamespace.GetTypeMember("A2");
var b1Class = m.GlobalNamespace.GetTypeMember("B1");
var b2Class = m.GlobalNamespace.GetTypeMember("B2");
var c1Class = m.GlobalNamespace.GetTypeMember("C1");
var c2Class = m.GlobalNamespace.GetTypeMember("C2");
var d1Class = m.GlobalNamespace.GetTypeMember("D1");
var d2Class = m.GlobalNamespace.GetTypeMember("D2");
var e1Class = m.GlobalNamespace.GetTypeMember("E1");
var e2Class = m.GlobalNamespace.GetTypeMember("E2");
Assert.Equal(1, fooMethod.GetAttributes(a1Class).Count());
Assert.Equal(1, fooMethod.GetAttributes(a2Class).Count());
Assert.Equal(1, fooMethod.GetReturnTypeAttributes().Where(a => a.AttributeClass == b1Class).Count());
Assert.Equal(1, fooMethod.GetReturnTypeAttributes().Where(a => a.AttributeClass == b2Class).Count());
var typeParam1 = fooMethod.TypeParameters[0];
Assert.Equal(1, typeParam1.GetAttributes(c1Class).Count());
Assert.Equal(1, typeParam1.GetAttributes(c2Class).Count());
var typeParam2 = fooMethod.TypeParameters[1];
Assert.Equal(1, typeParam2.GetAttributes(d1Class).Count());
Assert.Equal(1, typeParam2.GetAttributes(d2Class).Count());
var param = fooMethod.Parameters[0];
Assert.Equal(1, param.GetAttributes(e1Class).Count());
Assert.Equal(1, param.GetAttributes(e2Class).Count());
}
示例3: CheckForAttributeOnAccessor
private void CheckForAttributeOnAccessor(MethodSymbol symbol)
{
foreach (CSharpAttributeData attribute in symbol.GetAttributes())
{
if (attribute.IsTargetAttribute(symbol, AttributeDescription.CLSCompliantAttribute))
{
Location attributeLocation;
if (TryGetAttributeWarningLocation(attribute, out attributeLocation))
{
AttributeUsageInfo attributeUsage = attribute.AttributeClass.GetAttributeUsageInfo();
this.AddDiagnostic(ErrorCode.ERR_AttributeNotOnAccessor, attributeLocation, attribute.AttributeClass.Name, attributeUsage.GetValidTargetsErrorArgument());
break;
}
}
}
}