本文整理汇总了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);
}
示例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;
}
}
}
}
}