Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What changes require a dependent assembly to be redeployed?

Tags:

c#

.net

clr

At my workplace we deploy internal application by only replacing assemblies that have changed (not my idea).

We can tell which assemblies we need to deploy by looking at if the source files that are compiled into the assemblies have changed. Most of the time we don't need to redeploy assemblies that depend on assemblies that have changed. However we have found some cases where even though no source files in an assembly have changed, we need to redeploy it.

So far we know that any of these changes in an assembly, will require all dependent assemblies to need to be recompiled and deployed:

  • Constant changes
  • Enum definition changes (order of values)
  • Return type of a function changes and caller uses var (sometimes)
  • Namespace of a class changes to another already referenced namespace.

Are there any other cases that we're missing? I'm also open to arguments why this entire approach is flawed (although it's been used for years).

Edit To be clear, we're always recompiling, but only deploying assemblies where the source files in them have changed.

So anything that breaks compilation will be picked up (method name changes, etc.), since they require changes in the calling code.

like image 960
Ray Avatar asked Nov 03 '11 12:11

Ray


1 Answers

Here is another one:

Changes to optional parameter values.

The default values get directly compiled to the assembly using them (if not specified)

 public void MyOptMethod(int optInt = 5) {}

Any calling code such as this:

 theClass.MyOptMethod();

Will end up compiled to:

 theClass.MyOptMethod(5);

If you change the method to:

 public void MyOptMethod(int optInt = 10) {}

You will need to recompile all dependent assemblies if you want the new default to apply.


Additional changes that will require recompilation (thanks Polynomial):

  • Changes to generic type parameter constraints
  • Changes to method names (especially problematic when using reflection, as private methods may also be inspected)
  • Changes to exception handling (different exception type being thrown)
  • Changes to thread handling
  • Etc... etc... etc...

So - always recompile everything.

like image 91
Oded Avatar answered Sep 28 '22 07:09

Oded