[Mono-bugs] [Bug 496803] New: Cecil does not distinguish between TypeReference and imported TypeReference
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Apr 21 05:55:36 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=496803
Summary: Cecil does not distinguish between TypeReference and
imported TypeReference
Classification: Mono
Product: Mono: Class Libraries
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Cecil
AssignedTo: jbevain at novell.com
ReportedBy: msafar at novell.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
It's not obvious which Cecil's methods require to call Import for
TypeReference.
Here is proposed change which I am using fol CilWorker
Index: CilWorker.cs
===================================================================
--- CilWorker.cs (revision 131537)
+++ CilWorker.cs (working copy)
@@ -31,6 +31,12 @@
using System;
using SR = System.Reflection;
+ // TODO: Cannot use IMemberReference because it has some broken
dependencies
+ public interface IMemberReferenceProvider<T> where T : IMemberReference
+ {
+ T GetReference ();
+ }
+
public sealed class CilWorker {
MethodBody m_mbody;
@@ -98,6 +104,18 @@
return FinalCreate (opcode, field);
}
+ public Instruction Create<T> (OpCode opcode,
IMemberReferenceProvider<T> factory) where T : IMemberReference
+ {
+ if (factory == null)
+ throw new ArgumentNullException ("factory");
+
+ T reference = factory.GetReference ();
+ if (reference == null)
+ throw new ArgumentNullException ("reference");
+
+ return FinalCreate (opcode, reference);
+ }
+
public Instruction Create (OpCode opcode, string str)
{
if (str == null)
@@ -237,6 +255,13 @@
return instr;
}
+ public Instruction Emit<T> (OpCode opcode, IMemberReferenceProvider<T>
factory) where T : IMemberReference
+ {
+ Instruction instr = Create (opcode, factory);
+ Append (instr);
+ return instr;
+ }
+
public Instruction Emit (OpCode opcode, MethodReference meth)
{
Instruction instr = Create (opcode, meth);
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list