当前位置: 首页>>代码示例>>C#>>正文


C# MethodSymbol.GetReturnTypeAttributes方法代码示例

本文整理汇总了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));
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:RetargetCustomAttributes.cs

示例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());
        }
开发者ID:nemec,项目名称:roslyn,代码行数:31,代码来源:AttributeTests.cs

示例3: CheckForMeaninglessOnReturn

 private void CheckForMeaninglessOnReturn(MethodSymbol method)
 {
     Location attributeLocation;
     if (TryGetClsComplianceAttributeLocation(method.GetReturnTypeAttributes(), method, out attributeLocation))
     {
         this.AddDiagnostic(ErrorCode.WRN_CLS_MeaninglessOnReturn, attributeLocation);
     }
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:8,代码来源:ClsComplianceChecker.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.GetReturnTypeAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。