2

I am looking for a way to rename namespaces in an 3-rd party assembly during build process (and corresponding using statements in user code). I searched through fody's weavers but haven't found such thing. There is a pull request to ILRepack that does exact thing but it seems to be stale and not passing CI: https://github.com/gluck/il-repack/pull/268

Lets say I have two projects, A and B, both are nugetized and B has package dependency on A. Since I do not want to lock consumer on specific version on A when referencing B I am merging A into B with ILRepack and internalize A there, but despite A being internalized in B there is a type ambiguity on classes from A when consumer uses A and B in his project C.

NEST package (elasticsearch client https://github.com/elastic/elasticsearch-net) has done the exact thing with Newtonsoft.Json package.

szafir
  • 77
  • 8

1 Answers1

1

I have figured it out. There are two solutions:

ILRepack

ILRepack has options Internalize and RenameInternalized. Internalize will change public modifiers to internal for merged assemblies while RenameInternalized will append some random guids to these type names. All usages are also correctly renamed.

Assembly Rewriter

https://github.com/nullean/assembly-rewriter

Dotnet tool that rewrites assemblies and rename namespaces. It is limited to root namespace that is the same as assembly file name.

szafir
  • 77
  • 8