Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "MoDisco/CSharp"
(New page: The CSharp meta model : it is the reflect of C# language, as it has been defined in version 2.0 of "C# Language Specification" from Microsoft Corporation. J2SE5 meta model contains 81 met...) |
(Category:MoDisco) |
||
(22 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The CSharp | + | The CSharp metamodel is the reflection of the C# language, as defined in version 2.0 of "C# Language Specification" from Microsoft Corporation. |
− | + | The CSharp metamodel contains 81 metaclasses. | |
− | To better understand it, this page will introduce main features ( | + | To better understand it, this page will introduce the main features (metaclasses and links). |
− | + | ||
− | + | ||
+ | You could also browse the model definition '''csharp.ecore''' available in sources (see the [[#Install| install section]]). | ||
== Main meta classes == | == Main meta classes == | ||
Line 11: | Line 10: | ||
=== ASTNode === | === ASTNode === | ||
− | Every | + | Every metaclass (except metaclass '''Fragment''') inherits from '''ASTNode'''. |
− | As its name | + | As its name indicates, '''ASTNode''' represents a graph node. |
− | ASTNode has a reference to Comment | + | '''ASTNode''' has a reference to metaclass '''Comment''' because almost every csharp element could be associated to a comment (block or line comment). |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass ASTNode.jpg|frame|center|ASTNode meta class]] |
− | === | + | === Assembly, Namespace, Type === |
− | + | The root element of each CSharp model is an instance of the '''Assembly''' metaclass. It is a translation of the concept of csharp application, so it contains namespace declarations (instances of the '''Namespace''' metaclass). And namespace declarations contain type declarations (instances compatible with metaclass '''Type'''), and so on ... | |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp Assembly Namespace and Type.jpg|frame|center|Assembly Namespace and Type]] |
=== NamedElement & notion of Proxy === | === NamedElement & notion of Proxy === | ||
− | A lot of | + | A lot of csharp elements are "named", and this name can be considered as an identifier : methods, packages, types, variables, fields, ... |
− | So all | + | So all the corresponding metaclasses inherit from the '''NamedElement''' metaclass. It will be useful to resolve references in binding, see the [[#NamedElementRef|NamedElementRef]] metaclass. |
− | + | Another goal of this metaclass is to indicate for each element whether it is part of the current csharp application or not (element from an external .NET library). So external elements are tagged as proxy through a dedicated attribute and can be easily filtered. | |
− | For example, instruction " | + | For example, instruction "Trace.WriteLine" has been decomposed into two named elements (one class and one method) the definitions of which are not part of the current csharp application. So attribute '''proxy''' of these elements has been initialized to true. |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass NamedElement and its hierarchy.jpg|frame|center|NamedElement and its hierarchy]] |
=== NamedElementRef === | === NamedElementRef === | ||
− | To represent links between | + | To represent links between csharp elements, as the C# AST defines only string references, metaclass NamedElementRef initially contained only this information. |
− | But an important addition was to resolve | + | But an important addition was to resolve bindings between elements, so it is actually possible to navigate directly through the elements graph. It has been represented as a relationship from a '''NamedElementRef''' to a '''NamedElement''' (proxy or not). |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass NamedElementRef.jpg|frame|center|NamedElementRef meta class]] |
− | === | + | === InternalDeclaration === |
− | A type declaration has different kinds of contents : fields, methods, static block, initialization block or other type declarations. All of these elements are of type | + | A type declaration has different kinds of contents : fields, methods, static block, initialization block or other type declarations. All of these elements are of type '''InternalDeclaration''' metaclass. |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass InternalDeclaration and its hierarchy.jpg|frame|center|InternalDeclaration and its hierarchy]] |
=== Expressions === | === Expressions === | ||
− | Like in many languages, concept of expression exists in | + | Like in many languages, the concept of expression exists in C# : it is a portion of code, without declarations, and its evaluation returns a value, numerical or boolean or other ... |
− | For example, <source lang=" | + | For example, <source lang="csharp">++i</source> is an expression and will be translated into the concept of '''InfixExpression''' metaclass. |
− | All types of expressions shall inherit from Expression | + | All types of expressions shall inherit from metaclass '''Expression'''. |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass Expression and its hierarchy.jpg|frame|center|Expression and its hierarchy]] |
=== Statements === | === Statements === | ||
− | An "instruction" in | + | An "instruction" in C# is represented by the '''Statement''' metaclass. A block of code ('''Block''' metaclass) contains a collection of statements, and a block of code may be contained by a method. |
− | Some | + | Some examples of statements in C# : <source lang="csharp">if, while, for, do, ...</source> |
− | All of their definitions use concept of expression to separate value from instruction keyword. | + | All of their definitions use the concept of expression to separate the value from the instruction keyword. |
− | [[Image:MoDisco- | + | [[Image:MoDisco-CSharp metaclass Statement and its hierarchy.jpg|frame|center|Statement and its hierarchy]] |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Requirements == | == Requirements == | ||
Line 91: | Line 71: | ||
To use the plug-in you need: | To use the plug-in you need: | ||
* JDK 1.5 or above | * JDK 1.5 or above | ||
− | * a version of Eclipse 3.3 or above with the following set of | + | * a version of Eclipse 3.3 or above with the following set of plug-ins installed |
:* [[EMF|EMF]] 2.3.0 or higher | :* [[EMF|EMF]] 2.3.0 or higher | ||
+ | == Team == | ||
+ | Gabriel Barbier ([http://www.mia-software.com Mia-Software]) | ||
+ | |||
+ | Fabien Giquel ([http://www.mia-software.com Mia-Software]) | ||
+ | |||
+ | Frédéric Madiot ([http://www.mia-software.com Mia-Software]) | ||
== Install == | == Install == | ||
− | You will find a version of this plug-in attached in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=258281 following bug]. | + | You will find a version of this plug-in attached in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=258281 the following bug]. |
− | As IP review of this | + | As IP review of this plug-in is not finished, here are installation instructions : |
* Extract archive file in your Eclipse workspace, then use "import" menu to import this project. | * Extract archive file in your Eclipse workspace, then use "import" menu to import this project. | ||
− | * Use "export" menu to export this project as a | + | * Use "export" menu to export this project as a plug-in (Deployable plug-ins and fragments) in your Eclipse installation. Don't forget to choose the "Package plug-ins as individual jar archives" option. |
− | * re-start your Eclipse to take | + | * re-start your Eclipse to take this plug-in into account |
+ | |||
+ | == Associated Discoverers == | ||
+ | |||
+ | A first version of the C# discoverer : [[MoDisco/CSharpDiscoverer|CSharpDiscoverer]] | ||
+ | |||
+ | [[Category:MoDisco]] |
Latest revision as of 05:44, 13 January 2010
The CSharp metamodel is the reflection of the C# language, as defined in version 2.0 of "C# Language Specification" from Microsoft Corporation.
The CSharp metamodel contains 81 metaclasses. To better understand it, this page will introduce the main features (metaclasses and links).
You could also browse the model definition csharp.ecore available in sources (see the install section).
Contents
Main meta classes
ASTNode
Every metaclass (except metaclass Fragment) inherits from ASTNode. As its name indicates, ASTNode represents a graph node. ASTNode has a reference to metaclass Comment because almost every csharp element could be associated to a comment (block or line comment).
Assembly, Namespace, Type
The root element of each CSharp model is an instance of the Assembly metaclass. It is a translation of the concept of csharp application, so it contains namespace declarations (instances of the Namespace metaclass). And namespace declarations contain type declarations (instances compatible with metaclass Type), and so on ...
NamedElement & notion of Proxy
A lot of csharp elements are "named", and this name can be considered as an identifier : methods, packages, types, variables, fields, ... So all the corresponding metaclasses inherit from the NamedElement metaclass. It will be useful to resolve references in binding, see the NamedElementRef metaclass.
Another goal of this metaclass is to indicate for each element whether it is part of the current csharp application or not (element from an external .NET library). So external elements are tagged as proxy through a dedicated attribute and can be easily filtered. For example, instruction "Trace.WriteLine" has been decomposed into two named elements (one class and one method) the definitions of which are not part of the current csharp application. So attribute proxy of these elements has been initialized to true.
NamedElementRef
To represent links between csharp elements, as the C# AST defines only string references, metaclass NamedElementRef initially contained only this information. But an important addition was to resolve bindings between elements, so it is actually possible to navigate directly through the elements graph. It has been represented as a relationship from a NamedElementRef to a NamedElement (proxy or not).
InternalDeclaration
A type declaration has different kinds of contents : fields, methods, static block, initialization block or other type declarations. All of these elements are of type InternalDeclaration metaclass.
Expressions
Like in many languages, the concept of expression exists in C# : it is a portion of code, without declarations, and its evaluation returns a value, numerical or boolean or other ...
For example,++i
All types of expressions shall inherit from metaclass Expression.
Statements
An "instruction" in C# is represented by the Statement metaclass. A block of code (Block metaclass) contains a collection of statements, and a block of code may be contained by a method.
Some examples of statements in C# :if, while, for, do, ...
All of their definitions use the concept of expression to separate the value from the instruction keyword.
Requirements
To use the plug-in you need:
- JDK 1.5 or above
- a version of Eclipse 3.3 or above with the following set of plug-ins installed
- EMF 2.3.0 or higher
Team
Gabriel Barbier (Mia-Software)
Fabien Giquel (Mia-Software)
Frédéric Madiot (Mia-Software)
Install
You will find a version of this plug-in attached in the following bug.
As IP review of this plug-in is not finished, here are installation instructions :
- Extract archive file in your Eclipse workspace, then use "import" menu to import this project.
- Use "export" menu to export this project as a plug-in (Deployable plug-ins and fragments) in your Eclipse installation. Don't forget to choose the "Package plug-ins as individual jar archives" option.
- re-start your Eclipse to take this plug-in into account
Associated Discoverers
A first version of the C# discoverer : CSharpDiscoverer