Skip to content

A tool aiming to make it a little bit easier to learn Mono.Cecil

License

Notifications You must be signed in to change notification settings

54k1/cecilifier

 
 

Repository files navigation

Cecilifier

About

Cecilifier is a tool meant to make it easier to learn how to use Mono.Cecil a library used to manipulate MS IL. It was developed after the idea of asmifier. You can read more details about it in its announcement blog.

You can use it live in this site.

Feel free to send comments, issues, MR, etc; I cannot promise I'll be responsive but I'll do my best.

How to help

License

Cecilifier is licensed under MIT license.

Supported Features

  • Attribute declaration / usage

  • Type declaration

    • Class
    • Struct
    • Enum
    • Interfaces
  • Member declaration

    • Properties
    • Indexers
    • Methods
    • Fields
  • Exception handling

  • Single dimensional arrays

  • Static generic methods

  • Generics

    • Type / method instantiation
    • Type / Method definition
    • Generic events
    • Constraints
    • Co/Contra variance
  • Pointer types (int*, void*, etc)

  • Fixed statement

  • for statment

Unsupported Features

  • Events (wip, support most common cases)
  • default expression
  • Enumerator methods
  • Delegate (generic)
  • async/await
  • Newer C# syntax (expression bodied members, elvis operator, static import, to name some)
  • Much more :(

How to use it

  • The easiest way is to browse to its site.
  • Another alternative is to build and run it locally (see bellow)

Orthogonal to these options, after you Cecilifier some code you can create a project and debug the generated code to get more insight about how Mono.Cecil works.

How To build

In order to build it you need at least .Net Core SDK 3.1

  • Pull the git repo
  • Open a console in the folder with the pulled source code
  • run dotnet build

You can run the website locally by typing:

cd Cecilifier.Web

dotnet run

Then you can open a browser at http://localhost:8081

How to add tests

First, and most importantly, tests should be self contained, clearly describing what they are testing and run quickly (unfortunately it is very likely that some of the existing tests does not meet this criteria, but nevertheless, we should strive to ;)

Existing tests work basically taking a snippet of code, Cecilifying it (generating the Mono.Cecil API calls to produce an assembly equivalent to the compiled snippet), compiling it, and finally either comparing the two assemblies or comparing the generated IL for some method with the expected output as in this example.

Ideally all tests should use the assembly comparison approach (as opposed to forcing developers to store the expected IL) but in some cases the comparison code would became to complex and in such cases I think it is ok to store the expected IL (anyway, I try to minimize the number of such tests).

How to report issues

If you hit a problem and you think it is an issue/bug in the code please follow the steps to report it:

  • Search in the open / resolved issues to make sure it is not already known
  • If you cannot find anything open a new issue and do your best to:
    • add a failing test (see How to add tests)
    • Make the title/description as clear / detailed as possible (do not assume anything; add as much details as possible)

Including a failing test is the best way to ensure the processing of the issue will happen as quick as possible and avoid any unnecessary delays.

Community

You can use Cecilifier google group to ask for help, make suggestions, start discussions about potential improvements, etc. You can also reach me through twitter @adrianoverona

There's also a discord server (created on April/2020); feel free to join at https://discord.gg/7P2sCk9 (I cannot guarantee that I'll be responsive but I'll do my best).

Build Status

Build Status codecov

Potential improvements

Disclaimer(s)

  • TL;DR; Use at your own :)
  • I am not a web designer/developer, so keep your expectations low (regarding the web site)
  • I do not claim to be an expert in Mono.Cecil; the code certainly does not handle a lot of cases
  • I do not claim that the generated code is suitable or even correct - I do have tests though :)
  • I have not tried to clean up the code too much, so there are some really bad code duplication

Thanks

I'd like to thank JetBrains for donating me a Rider license.

About

A tool aiming to make it a little bit easier to learn Mono.Cecil

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 86.8%
  • JavaScript 8.1%
  • HTML 3.1%
  • CSS 1.9%
  • Dockerfile 0.1%