4 ms·
I also thought the same way at first, but Hot Reload in .NET is limited to simple actions like changing the body of a non-generic method. Changing anything in a
by nonbirithm 5y ago
I also thought the same way at first, but Hot Reload in .NET is limited to simple actions like changing the body of a non-generic method. Changing anything in a generic class, adding or removing new methods/fields/properties, changing the implemented interfaces of a class, etc. all require a restart.
Currently the generic class limitation impacts me severely and I still have to restart the program too often for my own liking, unfortunately. Otherwise it works pretty well.
- xg15 5y agoMakes sense and this definitely lowers the risk. However you could still end up with situations where the new method body assumes different constraints/invariants on field values than the old code, so calling the hotswapped method on existing objects could still lead to unexpected behaviour. Example: A class has a private read-only field int foo that can take any value and a DoStuff() method which uses foo's value. Now the constructor is hotswapped to validate that foo > 5 and DoStuff is hotswapped with an implementation that also assumes foo > 5. This is all good for new objects created after the hotswap - however calling DoStuff on objects created before the swap (which might have foo <= 5) is unsafe.