// ...
public abstract class Abstract { }
public class Implementation : Abstract
{
public int Field;
public string Property { get; set; }
}
public class Game : BaseGame
{
// ...
public Abstract _instance;
public override void Startup()
{
// ...
_instance = new Implementation
{
Field = 123,
Property = "!olleH dlroW"
};
// ...
}
// ...
}
Start Mocha, wait for the game to start
Save Game.cs to trigger a hotload
Witness
Notes
Abstract classes and their implementations can obviously be from different assemblies, not sure what a clean way to handle that would be. Maybe something like this would work:
If the old implementation type is from the assembly we're swapping out, attempt to get a class of the same name from the new assembly and instantiate that
Else, just make a new instance of the old implementation type (It's probably from some .NET or Mocha assembly or something)
Reproduction
Notes
Abstract classes and their implementations can obviously be from different assemblies, not sure what a clean way to handle that would be. Maybe something like this would work:
Just spitballing though