particleSystem.startSize vs particleSystem.main.startSize

The current solution that works is

gameObject.GetComponent<ParticleSystem>().startSize = 1

but VStudio 2017 reports that startSize is obsolete and should be replaced with main.startSize. But when I do that, I get an error:

Cannon modify the return value of
ParticleSystem.main because it is not
a variable.

So how should I set the start size value?

If you are writing new value to the ps, cache the module struct to a var first. If you are only reading the value, you can skip the module caching, but you still need to specify the module. Also in most case use the “modifier” variant which only requires one single float value.

ref: Particle System Modules - FAQ | Unity Blog

 var psm_main = ps.main;
 main.startSizeModifier = 1;