Compile time Warning/Error or runtime indication of missing replication lifetime

Maybe there is no way to do it reasonably, but I and others on my team have run into situations before where when adding a replicated property, we forgot to add a replication lifetime for the property, which of course causes the replication to not work. It can be hard to notice that the replication isn’t working until you reach a point at which you are testing the code, which often times can be long after you initially added the variable, which can lead to time spent trying to find a bug in your code, only to find it is simply that you forgot to add a replication tag.

My observation is that it would seem to be an error to add a replicated variable without a replication lifetime. I wonder if there is a way to have a compile time check with the UBT to make sure whenever you have replicated variables you are

  1. Calling Super::GetLifetimeReplicatedProps

  2. Calling some form of DOREPLIFETIME for each replicated variable you added.

In both these cases it can be hard to notice when you haven’t done this, to the point where i think it is worth adding compile time checks or looking into an alternate method of indicating replication lifetime information in generated code via the UBT through tags. I’m sure countless hours have been spent by people across UE4 b/c of this, to the point where it’s probably worth looking into changing the engine to account for future issues.

Thanks for reading!

1 Like

Hey friendly bump :). Any response from an engine dev on this?

1 Like

+1 to this - I’ve spent so long on many instances of this mistake. Although I’m getting better at remembering to check, it’d still be **** nice.

1 Like

I have spend and lost hours and days debugging when I realize forgot the DOREPLIFETIME, GetLifetimeReplicatedProps or GetLifetimeReplicatedProps on different occasions.