本文整理汇总了C#中Mono.Cecil.MethodDefinition.SetName方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.SetName方法的具体用法?C# MethodDefinition.SetName怎么用?C# MethodDefinition.SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.MethodDefinition
的用法示例。
在下文中一共展示了MethodDefinition.SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rename
/// <summary>
/// Rename the given method and all references to it from code.
/// </summary>
private void Rename(MethodDefinition method, string newName)
{
methodReferences = methodReferences ?? InterfaceHelper.GetReachableMethodReferencesByName(reachableMethods);
var resolver = new GenericsResolver(method.DeclaringType);
foreach (var methodRef in methodReferences[method.Name])
{
if (ReferenceEquals(method, methodRef))
continue;
if (methodRef.AreSameIncludingDeclaringType(method, resolver.Resolve))
{
methodRef.Name = newName;
}
}
method.SetName(newName);
}
示例2: Rename
/// <summary>
/// Rename the given method and all references to it from code.
///
/// Note that the passed lookup will not be accurate after completion of this method.
/// If you rename methods multiple times, but know that you will rename each single method
/// only once, this should not be a problem.
/// </summary>
public static void Rename(MethodDefinition method, string newName, ILookup<string, MethodReference> reachableMethodReferencesByMethodName)
{
var resolver = new GenericsResolver(method.DeclaringType);
// Rename reference to method
foreach (var methodRef in reachableMethodReferencesByMethodName[method.Name])
{
if (!ReferenceEquals(methodRef, method) && methodRef.AreSameIncludingDeclaringType(method, resolver.Resolve))
{
methodRef.Name = newName;
}
}
// Rename method itself
method.SetName(newName);
}