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


C# Symbol.GetAttributes方法代码示例

本文整理汇总了C#中Symbol.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.GetAttributes方法的具体用法?C# Symbol.GetAttributes怎么用?C# Symbol.GetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symbol的用法示例。


在下文中一共展示了Symbol.GetAttributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultForceComplete

        /// <summary>
        /// Used to force (source) symbols to a given state of completion.
        /// </summary>
        /// <param name="symbol">The owning source symbol.</param>
        internal void DefaultForceComplete(Symbol symbol)
        {
            Debug.Assert(symbol.RequiresCompletion);

            if (!HasComplete(CompletionPart.Attributes))
            {
                symbol.GetAttributes();
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:13,代码来源:SymbolCompletionState.cs

示例2: DefaultForceComplete

        /// <summary>
        /// Used to force (source) symbols to a given state of completion.
        /// </summary>
        /// <param name="symbol">The owning source symbol.</param>
        internal void DefaultForceComplete(Symbol symbol)
        {
            Debug.Assert(symbol.RequiresCompletion);

            if (!HasComplete(CompletionPart.Attributes))
            {
                symbol.GetAttributes();
            }

            // any other values are completion parts intended for other kinds of symbols
            NotePartComplete(CompletionPart.All);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:16,代码来源:SymbolCompletionState.cs

示例3: CheckAttributes

        private void CheckAttributes(Symbol s, AttributeArgs[] expected)
        {
            int i = 0;
            foreach (var sa in s.GetAttributes())
            {
                int j = 0;
                foreach (var pa in sa.CommonConstructorArguments)
                {
                    CheckConstructorArg(expected[i].Pos[j], pa.Value.ToString());
                    j += 1;
                }

                j = 0;
                foreach (var na in sa.CommonNamedArguments)
                {
                    CheckNamedArg(expected[i].Named[j], na);
                    j += 1;
                }
                i += 1;
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:21,代码来源:LoadingAttributes.cs

示例4: DumpAttributes

        private void DumpAttributes(Symbol s)
        {
            int i = 0;
            foreach (var sa in s.GetAttributes())
            {
                int j = 0;
                foreach (var pa in sa.CommonConstructorArguments)
                {
                    Console.WriteLine("{0} {1} {2}", pa.ToString());
                    j += 1;
                }

                j = 0;
                foreach (var na in sa.CommonNamedArguments)
                {
                    Console.WriteLine("{0} {1} {2} = {3}", na.Key, na.Value.ToString());
                    j += 1;
                }
                i += 1;
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:21,代码来源:LoadingAttributes.cs

示例5: AppendCustomAttributes

        private static void AppendCustomAttributes(StringBuilder result, Symbol symbol, string indent, bool inBlock)
        {
            var attributes = symbol.GetAttributes();
            if (attributes.Length == 0)
            {
                return;
            }

            if (!inBlock)
            {
                result.Append(indent);
                result.AppendLine("{");
            }

            string memberIndent = indent + "  ";

            foreach (var attribute in attributes)
            {
                result.Append(memberIndent);
                result.Append(".custom ");
                if (attribute.AttributeConstructor == null)
                {
                    result.Append("[Missing: ");
                    result.Append(attribute.AttributeClass);
                    result.Append("]");
                }
                else
                {
                    AppendMethod(result, (PEMethodSymbol)attribute.AttributeConstructor, indent: null, includeTypeName: true);
                }

                result.Append(" = (");

                int i = 0;
                foreach (var arg in attribute.ConstructorArguments)
                {
                    if (i > 0)
                    {
                        result.Append(", ");
                    }

                    AppendConstant(result, arg);
                    i++;
                }

                foreach (var arg in attribute.NamedArguments)
                {
                    if (i > 0)
                    {
                        result.Append(", ");
                    }

                    result.Append(arg.Key);
                    result.Append(" = ");
                    AppendConstant(result, arg.Value);
                    i++;
                }

                result.Append(")");
                result.AppendLine();
            }

            if (!inBlock)
            {
                result.Append(indent);
                result.AppendLine("}");
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:68,代码来源:WinMdDumpTest.cs

示例6: AssertNoAttributes

 private static void AssertNoAttributes(Symbol symbol)
 {
     Assert.Equal(0, symbol.GetAttributes().Length);
 }
开发者ID:nemec,项目名称:roslyn,代码行数:4,代码来源:AttributeTests.cs

示例7: GetSingleAttributeName

 private static string GetSingleAttributeName(Symbol symbol)
 {
     return symbol.GetAttributes().Single().AttributeClass.Name;
 }
开发者ID:nemec,项目名称:roslyn,代码行数:4,代码来源:AttributeTests.cs

示例8: CheckAttributePropagation

        private static string CheckAttributePropagation(Symbol symbol)
        {
            string result = "";

            if (symbol.GetAttributes("", "MyAttribute").Any())
            {
                result += "MyAttribute is present\n";
            }

            if (!symbol.GetAttributes("System.Diagnostics", "DebuggerNonUserCodeAttribute").Any())
            {
                result += "DebuggerNonUserCodeAttribute is missing\n";
            }

            if (!symbol.GetAttributes("System.Diagnostics", "DebuggerHiddenAttribute").Any())
            {
                result += "DebuggerHiddenAttribute is missing\n";
            }

            if (!symbol.GetAttributes("System.Diagnostics", "DebuggerStepperBoundaryAttribute").Any())
            {
                result += "DebuggerStepperBoundaryAttribute is missing\n";
            }

            if (!symbol.GetAttributes("System.Diagnostics", "DebuggerStepThroughAttribute").Any())
            {
                result += "DebuggerStepThroughAttribute is missing\n";
            }

            return result;
        }
开发者ID:AnthonyDGreen,项目名称:roslyn,代码行数:31,代码来源:AttributeTests_WellKnownAttributes.cs

示例9: TestAttributeRetargeting

            public void TestAttributeRetargeting(Symbol symbol)
            {
                // Verify GetAttributes()
                TestAttributeRetargeting(symbol.GetAttributes());

                // Verify GetAttributes(AttributeType from Retargeted assembly)
                TestAttributeRetargeting(symbol.GetAttributes(newMsCorLib_debuggerTypeProxyAttributeType));

                // Verify GetAttributes(AttributeType from Underlying assembly)
                Assert.Empty(symbol.GetAttributes(oldMsCorLib_debuggerTypeProxyAttributeType));

                // Verify GetAttributes(AttributeCtor from Retargeted assembly)
                TestAttributeRetargeting(symbol.GetAttributes(newMsCorLib_debuggerTypeProxyAttributeType));

                // Verify GetAttributes(AttributeCtor from Underlying assembly)
                Assert.Empty(symbol.GetAttributes(oldMsCorLib_debuggerTypeProxyAttributeType));

                // Verify GetAttributes(namespaceName, typeName, ctorSignature)
                TestAttributeRetargeting(symbol.GetAttributes(s_attribute));
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:RetargetCustomAttributes.cs


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