solini.blogg.se

Net reflector
Net reflector













net reflector
  1. #NET REFLECTOR HOW TO#
  2. #NET REFLECTOR CODE#
  3. #NET REFLECTOR SERIES#

The Visitor pattern makes it easier to deal with some of the complexities that can arise from the recursive nature of the language definitions. This also means that while parsing nearly every language structure, you may also encounter nearly any language structure. Both of these properties, are of type IExpression and can implement any interface derived from IExpression, including IBinaryExpression. For example, an IBinaryExpression is an IExpression with two properties, Left and Right. These show up widely in recursive definitions. There are two main base Interfaces in the Reflector.CodeModel namespace, IStatement and IExpression.

#NET REFLECTOR SERIES#

This makes their definitions recursive.Ī simple example in English is illustrated through the following series of phrases:Īs prevalent as this is with Natural Languages, it is even more widespread with computer programming languages. It is also true for programming languages like C#, VB, and Java. This is true for natural languages like English, French, and Spanish. Language components are defined in terms of themselves.

#NET REFLECTOR HOW TO#

Providing the details for how to process the various language structures is where the complexities come in. For example, this may be all that you need for a minimal implementation of VisitNameSpaceĪs in life, the devil is in the details. At a minimum, you should display an informative message about what is being viewed. When you leave a blank implementation then nothing will be displayed at that level in the TreeView. These various methods allow you to customize what gets displayed in the Disassembler window as the user clicks on the various levels in the TreeView.

#NET REFLECTOR CODE#

The ILanguageWriter provides various methods that will be called by Reflector when different types of code are to be processed.Ĭalled when you disassemble the Assembly referencesĬalled when you disassemble an Event DeclarationĬalled when you disassemble an ExpressionĬalled when you disassemble a Field declarationĬalled when you disassemble a Method declarationĬalled when you disassemble an embedded reference at a module levelĬalled when you disassemble a Property DeclarationĬalled when you disassemble an embedded ResourceĬalled when you disassemble a Statement in isolationĬalled when you disassemble a Type Declaration

net reflector

Specifically, we need to provide a Load and Unload method that will register our language with the LanguageManagerService The IPackage object will provide the details needed to register our language with Reflector. By themselves none of these are too difficult to implement. In our class library, we must provide an object implementing the Reflector.IPackage interface, the Interface, and the interface. Remember that an Add-in is just a class library. There are a handful of objects that you will need to implement in order to define a language.

net reflector

We don’t really care about how Reflector determined that we have a ConditionStatement, we simply focus on what our language needs to do when a ConditionStatement is found.

net reflector

To build our “language”, we need to write code explaining what to do when each of these objects are encountered. Reflector will present us with meaningful objects from the Reflector.CodeModel namespace based on the meta data from the Assembly being parsed. We won’t have to worry about most of this. The parser assembles these tokens into something meaningful, based on the grammar for your language. The lexical analyzer will separate a character string into valid tokens for your language. When creating a language from scratch you have to create the lexical analyzer and the parser. Here we will step through creating a “Reflector Language” that will result in the CodeDom code needed to generate the code that was parsed. For C#, VB.Net, etc, these objects are translated into the textual representation that will produce the same metadata that was converted. This includes creating your own “language” to disassemble to.įor our purposes, we will define a “Reflector Language” as a piece of code that converts an object from the Reflector object model into useful text. Reflector takes things a step further than this marvel, providing the mechanisms needed to add virtually any functionality that you find missing. The Metadata in the Assembly in translated to an appropriate representation in C# or VB or whatever languages you have installed. When you select “Disassemble”, this is what is happening in the background. Reflector does a wonderful job translating an Assembly into higher level languages. NET Reflector meets the CodeDom - Simple Talk Skip to content















Net reflector