Hello! I have a little problem. I have two projects that I try to
weave by my application.
these projects contains identical (in first look) applicatons, and I
want to introduce call of my object constructor. This constructor have
3 arguments:
public PropertyLevelArgs(Object context, String name, Func<TType>
getter, Action<TType> setter)
{
Name = name;
m_getter = getter;
m_setter = setter;
Context = context;
}
code:
var propertyArgsTypeDef =
module.Import(typeof(PropertyLevelArgs<>)).MakeGenericInstanceType(propertyType);
var propArgsCtor = propertyArgsTypeDef.ReferenceMethod(m =>
m.IsConstructor);
...
// push args
il.InsertBefore(fst, Instruction.Create(OpCodes.Newobj,
propArgsCtor));
Reference Method: http://pastebin.com/emptgDsi
MakeGenericInstanceType: http://pastebin.com/MgfKftEH
BUT! :)
I try to weave two projects. In first project all is ok, but in second
I have
IL_0020: newobj instance void class
[NSurgeon.BaseLibrary]NSurgeon.SDK.PropertyLevel.PropertyLevelArgs`1<float64>::.ctor(object,
string,
class [NSurgeon.TrainigGround]System.Func`1<!0>,
class [mscorlib]System.Action`1<!0>)
Why System.Func`1<!0> can have wrong reference?
On 23 май, 10:39, Jb Evain <[email protected]> wrote:
> On Mon, May 23, 2011 at 8:30 AM, Simon <[email protected]> wrote:
> > In this case let say I am running in the context of .net 4 but I am
> > modifying a silverlight assembly.
> > Will "typeof (Action<,>)" cause problems? Because I will be importing the
> > .net 4 type no the silverlight type.
>
> Yes it will, you have to use the Cecil type system in this case, and
> import the TypeDefinition from the SL corlib.
>
> Jb
--
--
mono-cecil