Skip to content

Hotloading throws when upgrading instances of abstract classes #28

@MuffinTastic

Description

@MuffinTastic

Reproduction

  1. Put this in Game.cs
// ...

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"
		};

		// ...
	}

	// ...
}
  1. Start Mocha, wait for the game to start
  2. Save Game.cs to trigger a hotload
  3. Witness
    image

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:

  1. 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
  2. Else, just make a new instance of the old implementation type (It's probably from some .NET or Mocha assembly or something)

Just spitballing though

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions