本文整理汇总了C#中Mono.Cecil.MemberReference类的典型用法代码示例。如果您正苦于以下问题:C# MemberReference类的具体用法?C# MemberReference怎么用?C# MemberReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberReference类属于Mono.Cecil命名空间,在下文中一共展示了MemberReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetMemberReference
public MemberReference GetMemberReference(IAssemblyResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
if (memberReference != null)
return memberReference;
// reload from filename
ReaderParameters readerParameters = new ReaderParameters();
// Use new assembly resolver instance so that the AssemblyDefinitions can be garbage-collected
// once the code is decompiled.
readerParameters.AssemblyResolver = resolver;
string typeName;
if (GetAssemblyAndType(FileName.ToString(), out assemblyFile, out typeName)) {
ModuleDefinition module = ModuleDefinition.ReadModule(assemblyFile, readerParameters);
TypeDefinition typeDefinition = module.GetType(typeName);
if (typeDefinition == null)
throw new InvalidOperationException("Could not find type");
memberReference = typeDefinition;
}
return memberReference;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:25,代码来源:DecompiledBreakpointBookmark.cs
示例2: CreateUsage
private MethodUsage CreateUsage(MemberReference operand, ModuleDefinition assembly, TypeDefinition type, MethodDefinition method, string testAssemblyPath)
{
if (operand == null)
return null;
Test test = new Test
{
PathToAssembly = Path.GetDirectoryName(testAssemblyPath),
AssemblyName = assembly.Assembly.Name.Name,
NamespaceName = type.Namespace,
ClassName = type.Name,
MethodName = method.Name
};
var instructionCall = new MethodUsage
{
AssemblyName = operand.DeclaringType.Scope.Name + ".dll",
NamespaceName = operand.DeclaringType.Namespace,
ClassName = operand.DeclaringType.Name,
MethodName = operand.Name,
TestCoverage = new List<Test> {test}
};
return instructionCall;
}
开发者ID:BenHall,项目名称:Seacrest,代码行数:25,代码来源:TestFinder.cs
示例3: AssertInstruction
internal static void AssertInstruction(Instruction actual, OpCode opCode, MemberReference expectedCtor)
{
Assert.AreEqual(opCode, actual.OpCode);
MethodReference actualCtor = (MethodReference)actual.Operand;
Assert.AreEqual(expectedCtor.DeclaringType.Name, actualCtor.DeclaringType.Name, opCode.ToString());
Assert.AreEqual(expectedCtor, actualCtor.Resolve(), opCode.ToString());
}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:7,代码来源:TACollectionsTestCaseBase.cs
示例4: IsStringConcat
static bool IsStringConcat (MemberReference member)
{
if (member == null || (member.Name != "Concat"))
return false;
return (member.DeclaringType.FullName == "System.String");
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:7,代码来源:AvoidConcatenatingCharsRule.cs
示例5: GetGenericContextOf
public Dictionary<string, GenericEntry> GetGenericContextOf(MemberReference memberReference)
{
var ret = new Dictionary<string, GenericEntry>();
GetMethodGenericArgumentsOn(memberReference, ret);
GetClassGenericArgumentsOn(memberReference, ret);
return ret;
}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:7,代码来源:GenericContext.cs
示例6: SetIndirectConstraintsOn
public void SetIndirectConstraintsOn(MemberReference reference, MemberReference parent, bool inInheritance)
{
if (reference == null) return;
if (parent == null) return;
//TODO handle inInheritance call
var def = reference.DeclaringType.ThreadSafeResolve();
if (def != null && def.IsInterface)
{
//coming back to an interface
var mdp = ((MethodReference)parent).ThreadSafeResolve();
var mdr = ((MethodReference)reference).ThreadSafeResolve();
if (mdp == null || mdr == null) return;
if (mdp.Parameters.Count != mdr.Parameters.Count) Console.WriteLine("not sure what to do?!");
for (var i = 0; i < mdp.Parameters.Count; i++)
{
var current = mdr.Parameters[i].GetTypeWithGenericResolve();
if (current == null) continue; ;
if (current.IsGenericParameter)
{
var par = mdp.Parameters[i].GetTypeWithGenericResolve();
if (par == null) continue;
if(!_limitations.ContainsKey(current.Name))
{
_limitations.Add(current.Name,
par.IsGenericParameter
? new GenericEntry(null, true, par.Name)
: new GenericEntry(par.ThreadSafeResolve(), false, null));
}
}
}
}
}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:32,代码来源:GenericContext.cs
示例7: BreakpointBookmark
public BreakpointBookmark(MemberReference member, AstLocation location, ILRange range, BreakpointAction action, DecompiledLanguages language) : base(member, location)
{
this.action = action;
this.ILRange = range;
this.Tooltip = string.Format("Language:{0}, Line:{1}, IL range:{2}-{3}", language.ToString(), location.Line, range.From, range.To);
this.Language = language;
}
开发者ID:qjlee,项目名称:ILSpy,代码行数:7,代码来源:BreakpointBookmark.cs
示例8: Analyze
public static void Analyze(MemberReference member)
{
if (member is TypeReference) {
TypeDefinition type = ((TypeReference)member).Resolve();
if (type != null)
AnalyzerTreeView.Instance.ShowOrFocus(new AnalyzedTypeTreeNode(type));
}
else if (member is FieldReference) {
FieldDefinition field = ((FieldReference)member).Resolve();
if (field != null)
AnalyzerTreeView.Instance.ShowOrFocus(new AnalyzedFieldTreeNode(field));
}
else if (member is MethodReference) {
MethodDefinition method = ((MethodReference)member).Resolve();
if (method != null)
AnalyzerTreeView.Instance.ShowOrFocus(new AnalyzedMethodTreeNode(method));
}
else if (member is PropertyReference) {
PropertyDefinition property = ((PropertyReference)member).Resolve();
if (property != null)
AnalyzerTreeView.Instance.ShowOrFocus(new AnalyzedPropertyTreeNode(property));
}
else if (member is EventReference) {
EventDefinition @event = ((EventReference)member).Resolve();
if (@event != null)
AnalyzerTreeView.Instance.ShowOrFocus(new AnalyzedEventTreeNode(@event));
}
}
开发者ID:Zvirja,项目名称:ILSpy,代码行数:28,代码来源:AnalyzeContextMenuEntry.cs
示例9: EnsureWellName
public static void EnsureWellName(MemberReference r)
{
if (r.mWellName != null) return;
if (IGNORE_WELLNAMING)
{
r.mWellName = r.Name;
return;
}
TypeReference tr = r as TypeReference;
if (tr != null) { CreateWellName(tr); return; }
FieldReference fr = r as FieldReference;
if (fr != null) { CreateWellName(fr); return; }
PropertyReference pr = r as PropertyReference;
if (pr != null) { CreateWellName(pr); return; }
MethodReference mr = r as MethodReference;
if (mr != null) { CreateWellName(mr); return; }
EventReference er = r as EventReference;
if (er != null) { CreateWellName(er); return; }
throw new Exception();
}
开发者ID:DKeeper1523,项目名称:ilspy_yh,代码行数:26,代码来源:YuehanNaming.cs
示例10: MemberIsHidden
public static bool MemberIsHidden(MemberReference member, DecompilerSettings settings)
{
MethodDefinition method = member as MethodDefinition;
if (method != null) {
if (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn)
return true;
if (settings.AnonymousMethods && method.Name.StartsWith("<", StringComparison.Ordinal) && method.IsCompilerGenerated())
return true;
}
TypeDefinition type = member as TypeDefinition;
if (type != null && type.DeclaringType != null) {
if (settings.AnonymousMethods && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated())
return true;
if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type))
return true;
}
FieldDefinition field = member as FieldDefinition;
if (field != null && field.IsCompilerGenerated()) {
if (settings.AnonymousMethods && field.Name.StartsWith("CS$<>", StringComparison.Ordinal))
return true;
if (settings.AutomaticProperties && field.Name.StartsWith("<", StringComparison.Ordinal) && field.Name.EndsWith("BackingField", StringComparison.Ordinal))
return true;
}
// event-fields are not [CompilerGenerated]
if (field != null && settings.AutomaticEvents && field.DeclaringType.Events.Any(ev => ev.Name == field.Name))
return true;
return false;
}
开发者ID:eldersantos,项目名称:ILSpy,代码行数:28,代码来源:AstBuilder.cs
示例11: GetMatchingElementMethod
private static MemberReference GetMatchingElementMethod(MemberReference memberReference)
{
var methodReference = memberReference as MethodReference;
var declaringType = (GenericInstanceType) memberReference.DeclaringType;
var elementType = declaringType.ElementType.ThreadSafeResolve();
if (elementType == null)
return null;
foreach (var current in elementType.Methods)
{
if(current.Name == memberReference.Name &&
current.Parameters.Count == methodReference.Parameters.Count)
{
//TODO need to check out params in cases where there are many matches
//for (int index = 0; index < methodReference.Parameters.Count; index++)
//{
// var method = methodReference.Parameters[index];
// var element = current.Parameters[index];
// var elementtype = element.GetTypeWithGenericResolve();
// var methodtype = method.GetTypeWithGenericResolve();
// if (elementtype == methodtype)
// {
// return current;
// }
//}
return current;
}
}
return null;
}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:29,代码来源:MemberReferenceExtensions.cs
示例12: ArgumentNullException
public IEnumerable<ExceptionSources> this [MemberReference member] {
get {
if (member == null)
throw new ArgumentNullException ("member");
MemberReference memberDef = member.Resolve ();
if (memberDef == null) {
ArrayType array = member.DeclaringType as ArrayType;
if (array != null && array.Rank > 1) {
// Multi-dimensional array; the member is runtime generated,
// doesn't "really" exist (in a form that we can resolve),
// so we can't do anything further.
return new ExceptionSources[0];
}
throw new NotSupportedException (string.Format (
"Unable to resolve member {0}::{1}.",
member.DeclaringType.FullName, member.Name));
}
string memberDecl = xdoc.GetDeclaration (member.Resolve ());
Dictionary<string, ExceptionSources> e;
if (!db.TryGetValue (memberDecl, out e)) {
e = new Dictionary<string, ExceptionSources> ();
var bodies = GetMethodBodies (member);
foreach (var body in bodies) {
if (body == null)
continue;
FillExceptions (body, e);
}
db.Add (memberDecl, e);
}
return e.Values;
}
}
开发者ID:carrie901,项目名称:mono,代码行数:32,代码来源:exceptions.cs
示例13: GetTestDescriptorFor
public TestDescriptor GetTestDescriptorFor(MemberReference refer)
{
var reference = refer as MethodReference;
if (reference == null) return null;
if (!IsTest(reference)) return null;
return new TestDescriptor(reference.Name, reference.Module.FullyQualifiedName, "simple.testing", reference.DeclaringType.FullName);
}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:7,代码来源:SimpleTestingTestIdentifier.cs
示例14: TryCreateAnalyzer
public static AnalyzerTreeNode TryCreateAnalyzer(MemberReference member)
{
if (CanShow(member))
return new AnalyzedEventTreeNode(member as EventDefinition);
else
return null;
}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:7,代码来源:AnalyzedEventTreeNode.cs
示例15: Walk
/// <summary>
/// Mark all children of the given member
/// </summary>
internal static void Walk(ReachableContext context, MemberReference member)
{
// Mark declaring type
member.DeclaringType.MarkReachable(context);
TypeReference typeRef;
MethodReference methodRef;
EventReference eventRef;
FieldReference fieldRef;
PropertyReference propertyRef;
if ((typeRef = member as TypeReference) != null)
{
Walk(context, typeRef);
}
else if ((methodRef = member as MethodReference) != null)
{
Walk(context, methodRef);
}
else if ((eventRef = member as EventReference) != null)
{
Walk(context, eventRef);
}
else if ((fieldRef = member as FieldReference) != null)
{
Walk(context, fieldRef);
}
else if ((propertyRef = member as PropertyReference) != null)
{
Walk(context, propertyRef);
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:35,代码来源:ReachableWalker.cs
示例16: BfMember
internal BfMember(BfCache cache, MemberReference memberRef, BfType type)
{
this._name = memberRef.Name;
this._fullName = type.FullName + "." + this._name;
this._cache = cache;
this._type = type;
}
开发者ID:akordowski,项目名称:Source-Code-Nitriq,代码行数:7,代码来源:BfMember.cs
示例17: GetJsName
public static string GetJsName(MemberReference memberRef)
{
var provider = GetProvider(memberRef);
if (provider == null)
return null;
return GetStringFromAttribute(provider, JsName);
}
开发者ID:JimmyJune,项目名称:DotWeb,代码行数:7,代码来源:AttributeHelper.cs
示例18: ApplyToMember
private bool ApplyToMember(Pattern matcher, MemberReference member, Action<MemberReference> action)
{
if (matcher.MemberMatcher != null && !_matcher.MatchesWildcard(matcher.MemberMatcher, member.Name))
return false;
action(member);
return true;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:8,代码来源:PatternApply.cs
示例19: CreateCodeMappings
/// <summary>
/// Create data in the CodeMappings and DecompiledMemberReferences.
/// </summary>
/// <param name="token">Token of the current method.</param>
/// <param name="member">Current member (MethodDefinition, PropertyDefinition, EventDefinition).</param>
/// <remarks>The token is used in CodeMappings; member (and its token) is used in DecompiledMemberReferences.</remarks>
protected virtual void CreateCodeMappings(int token, MemberReference member)
{
this.CodeMappings.Add(token, new List<MemberMapping>());
int t = member.MetadataToken.ToInt32();
if (!this.DecompiledMemberReferences.ContainsKey(t))
this.DecompiledMemberReferences.Add(t, member);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:14,代码来源:CodeMappings.cs
示例20: BreakpointBookmark
public BreakpointBookmark(MemberReference member, TextLocation location, int functionToken, ILRange range, BreakpointAction action)
: base(member, location)
{
this.action = action;
this.FunctionToken = functionToken;
this.ILRange = range;
this.Tooltip = string.Format("Line:{0}, IL range:{1}-{2}", location.Line, range.From, range.To);
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:8,代码来源:BreakpointBookmark.cs
注:本文中的Mono.Cecil.MemberReference类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论