0

Is it possible to create a stripped down .NET assembly that only contains method/class/interface definitions with all actual code removed (or replaced with NotImplemented exceptions)?

I want to be able to only compile against it and replace it with a full-fledged assembly before running.

kaalus
  • 4,475
  • 3
  • 29
  • 39
  • 6
    That's what interfaces/abstractions are for, so you can build against the signatures/etc and then at runtime you inject the full fat classes that implement the abstractions. If you store them in different assemblies then there you go. – 404 Dec 28 '16 at 00:08
  • Sure you can. You really don;t have to have 'Code' in a class and the methods can be empty and defined as virtual. – Sparrow Dec 28 '16 at 00:11
  • There are no tools that do this that I am aware of, although you could probably use Roslyn to do something like this, or change existing IL after compilation, PostSharp style. But is there any reason for doing this? A standard way for achieving this is through DI frameworks, i.e. your code shouldn't know about concrete implementations anyway. – vgru Dec 28 '16 at 00:13
  • Use interfaces and abstract classes as @eurotrash recommends. – Dan Wilson Dec 28 '16 at 00:13

0 Answers0