Description
Having no default constructor in a INetworkSerializable class crashes the editor without any information because when code is generated and includes a call to the method InitializeSerializer_ManagedINetworkSerializable, the new() type constraint is not satisfied.

Not trying to argue with the design principle, just with the bad ux of having to figure out why the editor is crashing. Having it not properly generate IL and have yell at you with a console log would be enough and a much better experience.
Reproduce Steps
- Have the following example class:
[Serializable]
public class PlayerProfile : INetworkSerializable {
[SerializeField]
private string _nickname;
public PlayerProfile() { }
public PlayerProfile(string nickname) {
_nickname = nickname;
}
public string Nickname => _nickname;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter {
serializer.SerializeValue(ref _nickname);
}
}
- Add it as a NetworkVariable like so:
public class Player : NetworkBehaviour {
private NetworkVariable<PlayerProfile> _profile;
}
- Trigger a recompile and observe the editor crash
Actual Outcome
The editor crashes without any details other than the crash log to identify what happened.
Expected Outcome
CodeGen fails gracefully with some way of letting you know that you're not allowed to not have a no-args ctor
Environment
- OS: Windows 11
- Unity Version: 2022.2.3f1
- Netcode Version: 1.2.0
- Netcode Commit: 789f093
Additional Context
Editor.log
Description
Having no default constructor in a INetworkSerializable class crashes the editor without any information because when code is generated and includes a call to the method
InitializeSerializer_ManagedINetworkSerializable, thenew()type constraint is not satisfied.Not trying to argue with the design principle, just with the bad ux of having to figure out why the editor is crashing. Having it not properly generate IL and have yell at you with a console log would be enough and a much better experience.
Reproduce Steps
Actual Outcome
The editor crashes without any details other than the crash log to identify what happened.
Expected Outcome
CodeGen fails gracefully with some way of letting you know that you're not allowed to not have a no-args ctor
Environment
Additional Context
Editor.log