Weird Behavior With PropertyType

8 views
Skip to first unread message

JasonBock

unread,
Nov 5, 2008, 3:28:56 PM11/5/08
to mono-cecil
I'm trying to emit a box opcode based on the value type of a given
property:

if(property.PropertyType.IsValueType)
{
worker.Append(worker.Create(OpCodes.Box,
property.PropertyType));
}

The problem is that this is what ends up in the IL (assume that the
property is a System.Int32):

box [mscorlib]System.Runtime.InteropServices.GuidAttribute

I thought that it would be this:

box int32

If I have a Guid-based property, this is what I see:

box
[CecilInjector.Attributes]CecilInjector.Attributes.ToStringAttribute

And I should have this:

box [mscorlib]System.Guid

The PropertyType value looks right in the debugger but something isn't
working as I thought it would. Any ideas why this is occuring, and
also what I can do to put the right type in?

Thanks,
Jason

JasonBock

unread,
Nov 5, 2008, 3:45:35 PM11/5/08
to mono-cecil
Never mind, I had to Import() it if it wasn't in the current assembly.
That fixed it.
Reply all
Reply to author
Forward
0 new messages