Somewhat related to this issue is that I am having issued making a call now 
to Nullable<Boolean>.HasValue but I am only able to replicate this in my 
actual program. The program is an attempt to add a Modding API to a game 
and it does this by parsing an XML file to figure out what needs to be 
inserted and where.

This file represents how Call OpCodes are handled.
https://github.com/7H3LaughingMan/PhiScript/blob/master/PhiPatcher/Instructions/Call.cs


This is the actual XML file with all the modifications. I will include the 
part that I am having issues with.
https://github.com/7H3LaughingMan/PhiScript/blob/master/PhiPatcher/Modifications.xml

<Instruction OpCode="Call" Assembly="CoreLibrary" Type="System.Nullable`1" 
Method="get_HasValue">
<GenericParameter Assembly="CoreLibrary" Type="System.Boolean" />
</Instruction>

This is the exception I am getting.
InvalidProgramException: Invalid IL code in 
Planetbase.ConstructionComponent:canProduce (): IL_000a: call     
 0x0a0001bc

And using ILSpy this is the resulting IL code.
IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1<bool
>::get_HasValue()


On Sunday, November 8, 2015 at 11:59:50 AM UTC-6, Jb Evain wrote:
>
> Hi Austin, 
>
> Yeah dealing with generics is not always a pleasant experience right now. 
>
> Here's code that works: 
>
> http://paste2.org/YeD09NEI 
>
> Always work with definitions until you need to create references in 
> your module, it's much easier. In this case, retrieve the definition 
> from get_Value, up until the point where you create a reference. 
>
> And then there's the MakeGeneric method that should be in 
> Mono.Cecil.Rocks but isn't. 
>
> Jb 
>
> On Sat, Nov 7, 2015 at 6:59 AM, Austin Brkich <[email protected] 
> <javascript:>> wrote: 
> > I am having issues trying to create a instruction to call 
> > Nullable<Boolean>.Value 
> > 
> > The closest I have come is by using the following code as it will 
> generate 
> > ILCode that appears to be almost identical to what it was originally. I 
> have 
> > also included the Test.exe that I am modifying, In this example I am 
> > replacing a call to Nullable<Boolean>.Value that was generated from the 
> > compiler with one generated by Mono.Cecil, but I am getting the 
> following 
> > error when trying to run the modified executable. 
> > 
> > https://gist.github.com/7H3LaughingMan/311662c07b8bf8f8d2c6 
> > https://dl.dropboxusercontent.com/u/7231478/Test.exe 
> > 
> > Unhandled Exception: System.TypeLoadException: Could not load type 
> > 'System.Nullable`1' from assembly 'Test, Version=1.0.0.0, 
> Culture=neutral, 
> > PublicKeyToken=null' due to value type mismatch. 
> >    at Test.Program.Main(String[] args) 
> > 
> > -- 
> > -- 
> > -- 
> > mono-cecil 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "mono-cecil" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to