Giter VIP home page Giter VIP logo

assembly-rewriter's Introduction

assembly-rewriter

Rewrites .NET assemblies with Mono.Cecil, to allow two different versions of the same assembly to be referenced within an application.

It assumes that the assembly DLL name is the top level namespace and rewrites

  1. the top level namespace for all types within the assembly
  2. assemblies in the order of dependencies first
  3. IL ldstr op codes if they start with the namespace
  4. compiler generated backing fields

This small program was written to allow different versions Elasticsearch .NET clients to be rewritten for benchmark comparisons. Your mileage may vary rewriting other assemblies :)

Installation

Distributed as a .NET tool so install using the following

dotnet tool install assembly-rewriter

Run

dotnet assembly-rewriter

You can omit dotnet if you install this as a global tool

Examples

Rewrite NEST, the Elasticsearch .NET high level client, version 6.2.0

assembly-rewriter -i C:/Nest.dll -o C:/Nest620.dll

Now, Nest620.dll and another version of Nest.dll can be referenced in the same project.

There's a small issue here however; both versions of NEST rely on Elasticsearch.Net.dll, so we should also rewrite this dependency at the same time, and update the references to Elasticsearch.Net within NEST to reference the new rewritten assembly

assembly-rewriter -i C:/Nest.dll -o C:/Nest620.dll -i C:/Elasticsearch.Net.dll -o C:/Elasticsearch.Net620.dll

Great! Now we can reference both in the same project.

If there are other direct dependencies that may version clash, these can be passed as well

assembly-rewriter -i C:/Nest.dll -o C:/Nest620.dll -i C:/Elasticsearch.Net.dll -o C:/Elasticsearch.Net620.dll -i C:/Newtonsoft.Json.dll -o C:/Newtonsoft.Json620.dll

Rewrite validation

You can check to see if everything expected has been rewritten using IL Disassembler

ildasm <rewritten>.dll /OUT=<rewritten>.il /NOBAR
Select-String -Path <rewritten>.il -Pattern '<original namespace>\.' -AllMatches | ft LineNumber,Line

License

Apache 2.0

assembly-rewriter's People

Contributors

flobernd avatar mpdreamz avatar russcam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

assembly-rewriter's Issues

Please support .NET SDK 7.0, 8.0

Title.

I would have thought this is as simple as adding ;net7.0;net8.0 to the TargetFrameworks in src/assembly-rewriter/assembly-rewriter.csproj but your CI workflow seems to setup a special SDK build from GitHub packages?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.