Property lookup by token issue

View: New views
3 Messages — Rating Filter:   Alert me  

Property lookup by token issue

by sergiy.sakharov () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

It seems that part of logic that is responsible for this(PropertyDefinition lookup by token) functionality has been forgotten to be implemented:
The only method that uses ReflectionReader.m_properties field is ReflectionReader.GetPropertyDefAt; and there is no ReflectionReader.ReadProperties() method defined like in AggressiveReflectionReader...

This results in exception in following code snippet:

Expression<Func<DateTime>> stringTrueRepresentation = () => DateTime.Now;
var token = ((MemberExpression)stringTrueRepresentation.Body).Member.MetadataToken;
var assemblyDef = AssemblyFactory.GetAssembly(typeof(DateTime).Assembly.Location);
var propDef = assemblyDef.MainModule.LookupByToken(new Mono.Cecil.Metadata.MetadataToken(token));

For the reference: I am using trunk version of Cecil..

Best Regards, Sergiy

Re: Property lookup by token issue

by Jb Evain-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

On 7/30/09, sergiy.sakharov <sakharov@...> wrote:
>  It seems that part of logic that is responsible for this(PropertyDefinition
>  lookup by token) functionality has been forgotten to be implemented:
>  The only method that uses ReflectionReader.m_properties field is
>  ReflectionReader.GetPropertyDefAt; and there is no
>  ReflectionReader.ReadProperties() method defined like in
>  AggressiveReflectionReader...

Nope, it's because the aggressive reflection reader, once it's done
reading the properties and the events, set m_properties and m_events
to null. Just comment out the lines 62 and 63 of the
AggressiveReflectionReader.

Thanks,

--
Jb Evain  <jb@...>

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---


Re: Property lookup by token issue

by sergiy.sakharov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Just wondering if this change is going to be placed under version control or it is something that should be i.e. tested beforehand / postponed for some reason?

Jb Evain-2 wrote:
Hi,

On 7/30/09, sergiy.sakharov <sakharov@gmail.com> wrote:
>  It seems that part of logic that is responsible for this(PropertyDefinition
>  lookup by token) functionality has been forgotten to be implemented:
>  The only method that uses ReflectionReader.m_properties field is
>  ReflectionReader.GetPropertyDefAt; and there is no
>  ReflectionReader.ReadProperties() method defined like in
>  AggressiveReflectionReader...

Nope, it's because the aggressive reflection reader, once it's done
reading the properties and the events, set m_properties and m_events
to null. Just comment out the lines 62 and 63 of the
AggressiveReflectionReader.

Thanks,

--
Jb Evain  <jb@nurv.fr>

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---
Best regards,
Sergiy