Since the documentation is warning against overriding GH_Component’s PostConstructor() “if not knowing what you’re doing”, I felt I should ask if it’s safe to override the method like so?:
GH_Component Component;
protected override void PostConstructor()
{
base.PostConstructor();
// This fake Component variable allows the code from a
// ScriptComponent code to run, unmodified, also if pasted
// into a Visual Studio version of the code
Component = this;
}
I think I know what I’m doing, but is there more to it than this?
What’s the earliest point in time when you need this additional functionality? The PostConstructor call into RegisterInputParams and RegisterOutputParams, so you could also do your work there.
Or you could convert your Component variable into a readonly field which just returns this:
protected GH_Component Component { get { return this; } }
Or you could assign the field from its declaration:
protected readonly GH_Component Component = this;
I think class level fields have their assignments run before the constructor is called.