本文整理汇总了C#中Mono.Cecil.MethodDefinition.GetDexNameAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.GetDexNameAttribute方法的具体用法?C# MethodDefinition.GetDexNameAttribute怎么用?C# MethodDefinition.GetDexNameAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.MethodDefinition
的用法示例。
在下文中一共展示了MethodDefinition.GetDexNameAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFinalImplementationName
private static string GetFinalImplementationName(MethodDefinition impl)
{
string finalName;
var importAttr = impl.GetDexOrJavaImportAttribute();
if (importAttr != null)
{
string descriptor, className;
importAttr.GetDexOrJavaImportNames(impl, out finalName, out descriptor, out className);
}
else
{
var dexNameAttr = impl.GetDexNameAttribute();
finalName = dexNameAttr.ConstructorArguments[0].Value.ToString();
}
return finalName;
}
示例2: GetMethodName
/// <summary>
/// Perform name conversion
/// </summary>
protected virtual string GetMethodName(MethodDefinition method, DexTargetPackage targetPackage)
{
// Handle special names
switch (method.Name)
{
case ".ctor":
return "<init>";
case ".cctor":
return "<clinit>";
}
// Handle regular names
// Test for overrides of dex/java imported methods
var javaBaseMethod = method.GetDexImportBaseMethod() ?? method.GetJavaImportBaseMethod();
if (javaBaseMethod != null)
{
var javaMethodRef = javaBaseMethod.GetReference(targetPackage, compiler.Module);
return javaMethodRef.Name;
}
// Test for overrides of interface methods
var interfaceJavaBaseMethod = method.GetDexImportBaseInterfaceMethod() ?? method.GetJavaImportBaseInterfaceMethod();
if (interfaceJavaBaseMethod != null)
{
var javaMethodRef = interfaceJavaBaseMethod.GetReference(targetPackage, compiler.Module);
return javaMethodRef.Name;
}
// If a dex name is specified, use that
var dexName = method.GetDexNameAttribute();
if (dexName != null)
{
return (string) dexName.ConstructorArguments[0].Value;
}
return NameConverter.GetConvertedName(xMethod);
}
示例3: ConvertInterfaceMethod
/// <summary>
/// Convert the given interface method if it has explicit implementations.
/// </summary>
private void ConvertInterfaceMethod(TypeDefinition iType, MethodDefinition iMethod, Dictionary<TypeDefinition, List<TypeDefinition>> interfaceToImplementingTypes)
{
var implementations = GetImplementations(iMethod, interfaceToImplementingTypes);
var iMethodIsJavaWithGenericParams = iMethod.IsJavaMethodWithGenericParams();
var iMethodContainsGenericParams = iMethod.ContainsGenericParameter;
if (!iMethodIsJavaWithGenericParams && !iMethodContainsGenericParams && (!implementations.Any(x => x.Item2.IsExplicitImplementation())))
{
// There are no explicit implementation.
// No need to convert
return;
}
// Rename method
string newName;
bool createExplicitStubs = true;
var oldName = iMethod.Name;
var attr = iMethod.GetDexOrJavaImportAttribute();
if (attr != null)
{
string className;
string memberName;
string descriptor;
attr.GetDexOrJavaImportNames(iMethod, out memberName, out descriptor, out className);
newName = memberName;
}
else if ((attr = iMethod.GetDexNameAttribute()) != null)
{
newName = (string) (attr.ConstructorArguments[0].Value);
createExplicitStubs = false;
}
else
{
var module = reachableContext.Compiler.Module;
var xiType = XBuilder.AsTypeReference(module, iType);
newName = methodNames.GetUniqueName(NameConverter.GetConvertedName(xiType) + "_" + iMethod.Name);
oldName = newName;
}
Rename(iMethod, newName);
// Update implementations
foreach (var typeAndImpl in implementations)
{
var type = typeAndImpl.Item1;
var impl = typeAndImpl.Item2;
if (impl.IsExplicitImplementation())
{
// Convert to implicit
impl.IsPublic = true;
// Rename
Rename(impl, newName);
// Update names of overrides
foreach (var @override in impl.Overrides)
{
@override.Name = newName;
}
}
else if (!(impl.HasDexImportAttribute() || impl.HasJavaImportAttribute()))
{
// Add stub redirecting explicit implementation to implicit implementation
if (createExplicitStubs/* && !type.IsInterface TODO: check what to do with interfaces*/)
{
CreateExplicitStub(type, impl, newName, oldName, iMethod, iMethodIsJavaWithGenericParams /*|| iMethodContainsGenericParams*/);
}
}
}
}