本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.GetReturnTypeAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol.GetReturnTypeAttributes方法的具体用法?C# MethodSymbol.GetReturnTypeAttributes怎么用?C# MethodSymbol.GetReturnTypeAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol
的用法示例。
在下文中一共展示了MethodSymbol.GetReturnTypeAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAttributeRetargeting_ReturnTypeAttributes
public void TestAttributeRetargeting_ReturnTypeAttributes(MethodSymbol symbol)
{
// Verify GetReturnTypeAttributes()
TestAttributeRetargeting(symbol.GetReturnTypeAttributes());
// Verify GetReturnTypeAttributes(AttributeType from Retargeted assembly)
TestAttributeRetargeting(symbol.GetReturnTypeAttributes().Where(a => a.AttributeClass == newMsCorLib_debuggerTypeProxyAttributeType));
// Verify GetReturnTypeAttributes(AttributeType from Underlying assembly) returns nothing. Shouldn't match to old attr type
Assert.Empty(symbol.GetReturnTypeAttributes().Where(a => a.AttributeClass == oldMsCorLib_debuggerTypeProxyAttributeType));
// Verify GetReturnTypeAttributes(AttributeCtor from Retargeted assembly)
TestAttributeRetargeting(symbol.GetReturnTypeAttributes().Where(a => a.AttributeConstructor == newMsCorLib_debuggerTypeProxyAttributeCtor));
// Verify GetReturnTypeAttributes(AttributeCtor from Underlying assembly) returns nothing. Shouldn't match to old attr type.
Assert.Empty(symbol.GetReturnTypeAttributes().Where(a => a.AttributeConstructor == oldMsCorLib_debuggerTypeProxyAttributeCtor));
}
示例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: CheckForMeaninglessOnReturn
private void CheckForMeaninglessOnReturn(MethodSymbol method)
{
Location attributeLocation;
if (TryGetClsComplianceAttributeLocation(method.GetReturnTypeAttributes(), method, out attributeLocation))
{
this.AddDiagnostic(ErrorCode.WRN_CLS_MeaninglessOnReturn, attributeLocation);
}
}