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


C# MethodDeclaration.Annotation方法代码示例

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


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

示例1: VisitMethodDeclaration

		public virtual void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
		{
			StartNode(methodDeclaration);
			var builder = methodDeclaration.Annotation<MethodDebugInfoBuilder>();
			if (builder != null)
				builder.StartPosition = writer.GetLocation();
			WriteAttributes(methodDeclaration.Attributes);
			WriteModifiers(methodDeclaration.ModifierTokens);
			var oldRef = currentMethodReference;
			currentMethodReference = new object();
			methodDeclaration.ReturnType.AcceptVisitor(this);
			Space();
			WritePrivateImplementationType(methodDeclaration.PrivateImplementationType);
			WriteIdentifier(methodDeclaration.NameToken);
			WriteTypeParameters(methodDeclaration.TypeParameters, CodeBracesRangeFlags.AngleBrackets);
			Space(policy.SpaceBeforeMethodDeclarationParentheses);
			WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses, CodeBracesRangeFlags.Parentheses);
			int count = 0;
			foreach (Constraint constraint in methodDeclaration.Constraints) {
				if (count-- <= 0) {
					cancellationToken.ThrowIfCancellationRequested();
					count = CANCEL_CHECK_LOOP_COUNT;
				}
				constraint.AcceptVisitor(this);
			}
			WriteMethodBody(methodDeclaration.Body);
			if (builder != null)
				builder.EndPosition = writer.GetLocation();
			currentMethodReference = oldRef;
			EndNode(methodDeclaration);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:31,代码来源:CSharpOutputVisitor.cs

示例2: VisitMethodDeclaration

        public override void VisitMethodDeclaration(MethodDeclaration e)
        {
            base.VisitMethodDeclaration(e);

            var md = e.Annotation<MethodDefinition>();
            if (md != null)
            {
                if (!e.PrivateImplementationType.IsNull && md.DeclaringType.IsCompilerGenerated())
                {
                    var convert = true;
                    if (md.DeclaringType.Interfaces.Count > 1)
                    {
                        var trInterface = e.PrivateImplementationType.Annotation<TypeReference>();
                        var hasSameNameInterfaces = md.DeclaringType.Interfaces.Select(x => x.Resolve()).Where(x => x == null || x.FullName != trInterface.FullName && x.Methods.Any(y => IsSameExceptReturnType(y, md)));
                        if (hasSameNameInterfaces.Any())
                        {
                            if (hasSameNameInterfaces.Any(x => x == null) ||
                                !trInterface.HasGenericParameters ||
                                hasSameNameInterfaces.Any(x => x.HasGenericParameters))
                            {
                                convert = false;
                            }
                        }
                    }
                    if (convert)
                    {
                        e.PrivateImplementationType = null;
                        e.Modifiers |= Modifiers.Public;
                    }
                }

                if (md.HasOverrides)
                {
                    var omd = md.Overrides.First().Resolve();
                    if (omd != null)
                    {
                        if (omd.IsGetter || omd.IsSetter)
                        {
                            // 转换为属性
                            if (omd.IsGetter) TryConverterMethodToProperty(e, omd);
                        }
                        else
                        {
                            e.Name = omd.WellName;
                        }
                    }
                }
            }
        }
开发者ID:DKeeper1523,项目名称:ilspy_yh,代码行数:49,代码来源:YuehanTransform.cs


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