[Blog Post Discussion] Clarifying API usage requirements via improved messaging

Hi everyone,

We're excited to share our team's latest blog post with you:

Clarifying API usage requirements via improved messaging
At times, it can be unclear under which conditions an API can or should be called. Not having this information readily available leads to writing code that relies on unintended side effects which may have not been explicitly stated in the past.

Questions, comments and suggestions are all welcome. We're looking forward to hearing from you!


In worst case scenario for issues caused by this, you could add a compatibility option in project settings to let the calls go through, so that people know they need to fix them, but doesn't completely break their code. At some point you could remove this option to force everyone to fix their code.

The error messages should really say something about why the API can't be used at such a time! It's always very frustrating when you do something that you think should work, and the engine just goes "no you can't". A simple "that data is currently being changed so using the call will lead to inconsistent results" at the end of the error message will go a long way to alleviate annoyance.

Also, whenever you add a warning/error like this, make sure that it's actually sensible. I still keep getting upset that this:

void OnValidate() {
    gameObject.tag = "Something";

Causes this: