I am in a situation where a lot of code could be simplified if it were possible to get the property info of a record type by calling it as if it existed on the type -- Record.fieldName or even something like propertyInfo<Record.fieldName>. The only way to get property info I know of is to reflect the type and then look up the field based on a string and that's something I want to avoid if possible. Being able to do this through Record.fieldName would give some hints if you had any typos.
#Easy Way to Get PropertyInfo of a Record's Field.
1 messages · Page 1 of 1 (latest)
Not really clear why but I guess you know of nameof. Otherwise generate what you need with myriad.
To get the name you can do nameof Unchecked.defaultof<Record>.fieldName, it's long but it works
I appreciate the responses. The context of what I am trying to do is https://github.com/Hillcrest-R-D/FORM/issues/26.
Myriad wouldn't be an option here and the nameof thing is exactly what I'm trying to avoid but its implementation might shed light on a way to achieve what I want.