What are the following constructs in Mono.Cecil referring to in C#?

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

What are the following constructs in Mono.Cecil referring to in C#?

by yeeen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can someone explain what are these referring to in Mono.Cecil?
TypeReference, ExternType, Override, NestedType, PInvokeInfo, SecurityDeclaration and CustomAttribute and MarshalSpec
Best if can illustrate with examples. Will appreciate even if u don't know all, but still help me in understanding those u know.
 
What is TerminateModuleDefinition doing in BaseReflectionVisitor? What is the use and how to call it?

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


Re: What are the following constructs in Mono.Cecil referring to in C#?

by Jb Evain-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey,

On 10/4/09, Wee Li Yen <weeliyen@...> wrote:
> Can someone explain what are these referring to in Mono.Cecil?
> TypeReference, ExternType, Override, NestedType, PInvokeInfo,
> SecurityDeclaration and CustomAttribute and MarshalSpec
> Best if can illustrate with examples.

I suggest you have a look at the ECMA-335 document. Cecil is basically
mapping the metadata layout that is decribed is the document into an
objet model.

> What is TerminateModuleDefinition doing in BaseReflectionVisitor? What is
> the use and how to call it?

The visitor pattern implemented in Cecil is kind of broken. I strongly
suggest you avoid using it, and implement your own visit mechanism. In
this particular case, it's just a method called after a module
definition has been completely visited.

--
Jb Evain  <jb@...>

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


Re: What are the following constructs in Mono.Cecil referring to in C#?

by yeeen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



But I realised there are a lot of Visitors inside Cecil...
Which do I use if I want to accomplish sth like
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.cdt.doc.isv/reference/api/org/eclipse/cdt/core/dom/ast/ASTVisitor.html
in eclipse?

If really there is no visitor pattern suitable for me...
Would implementing my own visitor without any existing visitor to extend be
difficult?


--------------------------------------------------
From: "Jb Evain" <jb@...>
Sent: Sunday, October 04, 2009 11:25 PM
To: <mono-cecil@...>
Subject: [mono-cecil] Re: What are the following constructs in Mono.Cecil
referring to in C#?

>
> Hey,
>
> On 10/4/09, Wee Li Yen <weeliyen@...> wrote:
>> Can someone explain what are these referring to in Mono.Cecil?
>> TypeReference, ExternType, Override, NestedType, PInvokeInfo,
>> SecurityDeclaration and CustomAttribute and MarshalSpec
>> Best if can illustrate with examples.
>
> I suggest you have a look at the ECMA-335 document. Cecil is basically
> mapping the metadata layout that is decribed is the document into an
> objet model.
>
>> What is TerminateModuleDefinition doing in BaseReflectionVisitor? What is
>> the use and how to call it?
>
> The visitor pattern implemented in Cecil is kind of broken. I strongly
> suggest you avoid using it, and implement your own visit mechanism. In
> this particular case, it's just a method called after a module
> definition has been completely visited.
>
> --
> Jb Evain  <jb@...>
>
> >
>

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


Re: What are the following constructs in Mono.Cecil referring to in C#?

by yeeen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I suggest you have a look at the ECMA-335 document. Cecil is basically
> mapping the metadata layout that is decribed is the document into an
> objet model.

Can u tell me more specifically where should I look at? I search for
"metadata" but still can't find the info I want.
So I choose "PInvokeInfo" and try to search for it. I still can't it in the
file.


--------------------------------------------------
From: "Jb Evain" <jb@...>
Sent: Sunday, October 04, 2009 11:25 PM
To: <mono-cecil@...>
Subject: [mono-cecil] Re: What are the following constructs in Mono.Cecil
referring to in C#?

>
> Hey,
>
> On 10/4/09, Wee Li Yen <weeliyen@...> wrote:
>> Can someone explain what are these referring to in Mono.Cecil?
>> TypeReference, ExternType, Override, NestedType, PInvokeInfo,
>> SecurityDeclaration and CustomAttribute and MarshalSpec
>> Best if can illustrate with examples.
>
> I suggest you have a look at the ECMA-335 document. Cecil is basically
> mapping the metadata layout that is decribed is the document into an
> objet model.
>
>> What is TerminateModuleDefinition doing in BaseReflectionVisitor? What is
>> the use and how to call it?
>
> The visitor pattern implemented in Cecil is kind of broken. I strongly
> suggest you avoid using it, and implement your own visit mechanism. In
> this particular case, it's just a method called after a module
> definition has been completely visited.
>
> --
> Jb Evain  <jb@...>
>
> >
>

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


Re: What are the following constructs in Mono.Cecil referring to in C#?

by Jonathan Pryor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sun, 2009-10-04 at 15:49 +0800, Wee Li Yen wrote:
> Can someone explain what are these referring to in Mono.Cecil?
> TypeReference,

A reference to a type (which may be present within another assembly).

For example, if you compile the code:

        Console.WriteLine();

the IL will be:

        call void class [mscorlib]System.Console::WriteLine()

which in Mono.Cecil will be a MethodReference to
System.Console.WriteLine(), and MethodReference.DeclaringType will be a
TypeReference to System.Console.

>  ExternType, Override,

In this class:

        class Demo {
                public override string ToString() {return "demo";}
        }

The virtual method System.Object.ToString() is overridden.  All
overridden methods are present within an Overrides table for a type.

> NestedType,

A type declared within another type, e.g.:

        class List<T> {
                public struct Enumerator {}
        }

List<T>.Enumerator is a nested type.

>  PInvokeInfo,

When you use the [DllImport] attribute on a method.

>  SecurityDeclaration

Many System.Security attributes aren't saved as normal custom attributes
in IL, but instead are stored "specially".  Thus, there is a specific
table to store these "attributes".

(i.e. they only look like custom attributes within C# source, much like
[Serializable], but they're not really custom attributes.)

> and CustomAttribute

Used to store custom attributes:

        [AttributeUsage(AttributeTargets.All)]
        class FooAttribute : Attribute {
                public FooAttribute(string foo) {}
        }

        [Foo ("this is a custom attribute!")]
        class Bar {}

> and MarshalSpec

Used for custom marshaling.  Usually used only for P/Invoke marshaling.

 - Jon




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


Re: What are the following constructs in Mono.Cecil referring to in C#?

by Fabian Schmied :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>> I suggest you have a look at the ECMA-335 document. Cecil is basically
>> mapping the metadata layout that is decribed is the document into an
>> objet model.
>
> Can u tell me more specifically where should I look at? I search for
> "metadata" but still can't find the info I want.

Partition II ( Metadata definition and semantics); most notably
chapter 22 (Metadata logical format: tables). (That's from the 4th
edition from June 2006.)

Regards,
Fabian

> --------------------------------------------------
> From: "Jb Evain" <jb@...>
> Sent: Sunday, October 04, 2009 11:25 PM
> To: <mono-cecil@...>
> Subject: [mono-cecil] Re: What are the following constructs in Mono.Cecil
> referring to in C#?
>
>>
>> Hey,
>>
>> On 10/4/09, Wee Li Yen <weeliyen@...> wrote:
>>> Can someone explain what are these referring to in Mono.Cecil?
>>> TypeReference, ExternType, Override, NestedType, PInvokeInfo,
>>> SecurityDeclaration and CustomAttribute and MarshalSpec
>>> Best if can illustrate with examples.
>>
>> I suggest you have a look at the ECMA-335 document. Cecil is basically
>> mapping the metadata layout that is decribed is the document into an
>> objet model.
>>
>>> What is TerminateModuleDefinition doing in BaseReflectionVisitor? What is
>>> the use and how to call it?
>>
>> The visitor pattern implemented in Cecil is kind of broken. I strongly
>> suggest you avoid using it, and implement your own visit mechanism. In
>> this particular case, it's just a method called after a module
>> definition has been completely visited.
>>
>> --
>> Jb Evain  <jb@...>
>>
>> >
>>
>
> >
>

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