本文整理汇总了C#中dnlib.DotNet.MethodSig类的典型用法代码示例。如果您正苦于以下问题:C# MethodSig类的具体用法?C# MethodSig怎么用?C# MethodSig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodSig类属于dnlib.DotNet命名空间,在下文中一共展示了MethodSig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDelegateType
protected static TypeDef GetDelegateType(RPContext ctx, MethodSig sig)
{
TypeDef ret;
if (ctx.Delegates.TryGetValue(sig, out ret))
return ret;
ret = new TypeDefUser(ctx.Name.ObfuscateName(ctx.Method.DeclaringType.Namespace, RenameMode.Unicode), ctx.Name.RandomName(), ctx.Module.CorLibTypes.GetTypeRef("System", "MulticastDelegate"));
ret.Attributes = TypeAttributes.NotPublic | TypeAttributes.Sealed;
var ctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(ctx.Module.CorLibTypes.Void, ctx.Module.CorLibTypes.Object, ctx.Module.CorLibTypes.IntPtr));
ctor.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
ctor.ImplAttributes = MethodImplAttributes.Runtime;
ret.Methods.Add(ctor);
var invoke = new MethodDefUser("Invoke", sig.Clone());
invoke.MethodSig.HasThis = true;
invoke.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot;
invoke.ImplAttributes = MethodImplAttributes.Runtime;
ret.Methods.Add(invoke);
ctx.Module.Types.Add(ret);
foreach (IDnlibDef def in ret.FindDefinitions()) {
ctx.Marker.Mark(def);
ctx.Name.SetCanRename(def, false);
}
ctx.Delegates[sig] = ret;
return ret;
}
示例2: Create
public static MethodDefOptions Create(UTF8String name, MethodSig methodSig) {
return new MethodDefOptions {
ImplAttributes = MethodImplAttributes.IL | MethodImplAttributes.Managed,
Attributes = MethodAttributes.Public | MethodAttributes.ReuseSlot | MethodAttributes.HideBySig | (methodSig.HasThis ? 0 : MethodAttributes.Static),
Name = name,
MethodSig = methodSig,
ImplMap = null,
};
}
示例3: ResolveGenericArgs
MethodSig ResolveGenericArgs(MethodSig sig, MethodSig old) {
sig.RetType = ResolveGenericArgs(old.RetType);
foreach (TypeSig p in old.Params)
sig.Params.Add(ResolveGenericArgs(p));
sig.GenParamCount = old.GenParamCount;
if (sig.ParamsAfterSentinel != null) {
foreach (TypeSig p in old.ParamsAfterSentinel)
sig.ParamsAfterSentinel.Add(ResolveGenericArgs(p));
}
return sig;
}
示例4: CorPropertyInfo
public CorPropertyInfo(CorType ownerType, uint token, uint getToken, uint setToken, string name, MethodSig getSig, MethodSig setSig, MethodAttributes getMethodAttributes, DebuggerBrowsableState? debuggerBrowsableState) {
this.OwnerType = ownerType;
this.Token = token;
this.GetToken = getToken;
this.SetToken = setToken;
this.Name = name;
this.GetSig = getSig;
this.SetSig = setSig;
this.GetMethodAttributes = getMethodAttributes;
this.DebuggerBrowsableState = debuggerBrowsableState;
}
示例5: MethodDefOptions
public MethodDefOptions(MethodDef method) {
this.ImplAttributes = method.ImplAttributes;
this.Attributes = method.Attributes;
this.Name = method.Name;
this.MethodSig = method.MethodSig;
this.ImplMap = method.ImplMap;
this.CustomAttributes.AddRange(method.CustomAttributes);
this.DeclSecurities.AddRange(method.DeclSecurities);
this.ParamDefs.AddRange(method.ParamDefs);
this.GenericParameters.AddRange(method.GenericParameters);
this.Overrides.AddRange(method.Overrides);
}
示例6: Resolve
/// <summary>
/// Resolves the method signature with the specified generic arguments.
/// </summary>
/// <param name="methodSig">The method signature.</param>
/// <param name="typeGenArgs">The type generic arguments.</param>
/// <returns>Resolved method signature.</returns>
/// <exception cref="System.ArgumentException">No generic arguments to resolve.</exception>
public static MethodSig Resolve(MethodSig methodSig, IList<TypeSig> typeGenArgs) {
if (typeGenArgs == null)
throw new ArgumentException("No generic arguments to resolve.");
var resolver = new GenericArgumentResolver();
resolver.genericArguments = new GenericArguments();
resolver.recursionCounter = new RecursionCounter();
if (typeGenArgs != null)
resolver.genericArguments.PushTypeArgs(typeGenArgs);
return resolver.ResolveGenericArgs(methodSig);
}
示例7: MethodDefOptions
public MethodDefOptions(MethodDef method) {
ImplAttributes = method.ImplAttributes;
Attributes = method.Attributes;
SemanticsAttributes = method.SemanticsAttributes;
RVA = method.RVA;
Name = method.Name;
MethodSig = method.MethodSig;
ImplMap = method.ImplMap;
CustomAttributes.AddRange(method.CustomAttributes);
DeclSecurities.AddRange(method.DeclSecurities);
ParamDefs.AddRange(method.ParamDefs);
GenericParameters.AddRange(method.GenericParameters);
Overrides.AddRange(method.Overrides);
}
示例8: MemberRefUser
/// <summary>
/// Constructor
/// </summary>
/// <param name="module">Owner module</param>
/// <param name="name">Name of method ref</param>
/// <param name="sig">Method sig</param>
/// <param name="class">Owner of method</param>
public MemberRefUser(ModuleDef module, UTF8String name, MethodSig sig, IMemberRefParent @class) {
this.module = module;
this.name = name;
[email protected] = @class;
this.signature = sig;
}
示例9: MethodSigFullName
/// <summary>
/// Returns the full name of a method sig
/// </summary>
/// <param name="methodSig">Method sig</param>
/// <returns>Method sig full name</returns>
public static string MethodSigFullName(MethodSig methodSig) {
var fnc = new FullNameCreator(false, null);
fnc.CreateMethodFullName(null, null, methodSig, null);
return fnc.Result;
}
示例10: StandAloneSigUser
/// <summary>
/// Constructor
/// </summary>
/// <param name="methodSig">A method sig</param>
public StandAloneSigUser(MethodSig methodSig) {
this.signature = methodSig;
}
示例11: MatchProperty
private static bool MatchProperty(PropertyDef mCandidate, MethodSig mCandidateSig, PropertyDef mProperty)
{
if (mCandidate == null || mCandidateSig == null || mProperty == null)
return false;
if (mCandidate.Name != mProperty.Name)
return false;
var accMeth = mCandidate.GetMethod ?? mCandidate.SetMethod;
if (accMeth != null && accMeth.HasOverrides)
return false;
if (mProperty.PropertySig == null || mCandidateSig.GenParamCount != mProperty.PropertySig.GenParamCount)
return false;
return new SigComparer().Equals(mCandidateSig.Params, mProperty.PropertySig.Params);
}
示例12: MatchMethod
private static bool MatchMethod(MethodDef mCandidate, MethodSig mCandidateSig, MethodDef mMethod)
{
if (mCandidate == null || mCandidateSig == null || mMethod == null)
return false;
if (mCandidate.Name != mMethod.Name)
return false;
if (mCandidate.HasOverrides)
return false;
if (mCandidate.IsSpecialName != mMethod.IsSpecialName)
return false;
if (mCandidate.HasGenericParameters || mMethod.HasGenericParameters) {
if (!mCandidate.HasGenericParameters || !mMethod.HasGenericParameters || mCandidate.GenericParameters.Count != mMethod.GenericParameters.Count)
return false;
}
if (mMethod.MethodSig == null || mCandidateSig.Params.Count != mMethod.MethodSig.Params.Count)
return false;
if (mCandidate.Parameters.Count != mMethod.Parameters.Count)
return false;
for (int i = 0; i < mCandidate.Parameters.Count; i++) {
var p1 = mCandidate.Parameters[i];
var p2 = mMethod.Parameters[i];
if (p1.IsHiddenThisParameter != p2.IsHiddenThisParameter)
return false;
if (p1.IsHiddenThisParameter)
continue;
var pd1 = p1.ParamDef ?? new ParamDefUser();
var pd2 = p2.ParamDef ?? new ParamDefUser();
if (pd1.IsIn != pd2.IsIn || pd1.IsOut != pd2.IsOut)
return false;
}
return new SigComparer().Equals(mCandidateSig.Params, mMethod.MethodSig.Params);
}
示例13: MethodFullName
/// <summary>
/// Returns the full name of a method
/// </summary>
/// <param name="declaringType">Declaring type full name or <c>null</c> if none</param>
/// <param name="name">Name of method or <c>null</c> if none</param>
/// <param name="methodSig">Method signature</param>
/// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param>
/// <param name="methodGenArgs">Method generic arguments or <c>null</c> if none</param>
/// <returns>Method full name</returns>
public static string MethodFullName(string declaringType, string name, MethodSig methodSig, IList<TypeSig> typeGenArgs, IList<TypeSig> methodGenArgs) {
var fnc = new FullNameCreator(false, null);
if (typeGenArgs != null || methodGenArgs != null)
fnc.genericArguments = new GenericArguments();
if (typeGenArgs != null)
fnc.genericArguments.PushTypeArgs(typeGenArgs);
if (methodGenArgs != null)
fnc.genericArguments.PushMethodArgs(methodGenArgs);
fnc.CreateMethodFullName(declaringType, name, methodSig);
return fnc.Result;
}
示例14: Write
public static void Write(this ITextOutput writer, MethodSig sig, IMethod method = null)
{
if (sig == null && method != null)
sig = method.MethodSig;
if (sig == null)
return;
if (sig.ExplicitThis) {
writer.Write("instance", TextTokenType.Keyword);
writer.WriteSpace();
writer.Write("explicit", TextTokenType.Keyword);
writer.WriteSpace();
}
else if (sig.HasThis) {
writer.Write("instance", TextTokenType.Keyword);
writer.WriteSpace();
}
sig.RetType.WriteTo(writer, ILNameSyntax.SignatureNoNamedTypeParameters);
writer.WriteSpace();
if (method != null) {
if (method.DeclaringType != null) {
method.DeclaringType.WriteTo(writer, ILNameSyntax.TypeName);
writer.Write("::", TextTokenType.Operator);
}
MethodDef md = method as MethodDef;
if (md != null && md.IsCompilerControlled) {
writer.WriteReference(Escape(method.Name + "$PST" + method.MDToken.ToInt32().ToString("X8")), method, TextTokenHelper.GetTextTokenType(method));
}
else {
writer.WriteReference(Escape(method.Name), method, TextTokenHelper.GetTextTokenType(method));
}
}
MethodSpec gim = method as MethodSpec;
if (gim != null && gim.GenericInstMethodSig != null) {
writer.Write('<', TextTokenType.Operator);
for (int i = 0; i < gim.GenericInstMethodSig.GenericArguments.Count; i++) {
if (i > 0) {
writer.Write(',', TextTokenType.Operator);
writer.WriteSpace();
}
gim.GenericInstMethodSig.GenericArguments[i].WriteTo(writer);
}
writer.Write('>', TextTokenType.Operator);
}
writer.Write("(", TextTokenType.Operator);
var parameters = sig.GetParameters();
for(int i = 0; i < parameters.Count; ++i) {
if (i > 0) {
writer.Write(',', TextTokenType.Operator);
writer.WriteSpace();
}
parameters[i].WriteTo(writer, ILNameSyntax.SignatureNoNamedTypeParameters);
}
writer.Write(")", TextTokenType.Operator);
}
示例15: Resolve
/// <summary>
/// Resolves the generic parameters in the specified method signature.
/// </summary>
/// <param name="methodSig">The method signature.</param>
/// <returns>Resolved method signature.</returns>
public MethodSig Resolve(MethodSig methodSig)
{
return ResolveGenericArgs(methodSig);
}