Issue with record-reflection in Extensions with P9 Amsterdam

Issue with record-reflection in Extensions with P9 Amsterdam


using P9-Amsterdam and for some reason this piece of code isn't working as expected anymore:
the something here is never "hit"
I am simply casting ToObject(Var1) with Var1 as a structure of Type Foo, which has 2 attributes...

What's the "new" way of using this?

              FieldInfo ParametersBaseStruct = parameters.GetType().GetFields()[0];
                object ParametersValueStruct = ParametersBaseStruct.GetValue(parameters);
                FieldInfo[] ParametersAttrs = ParametersValueStruct.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                NrOfParameters = 0;
                foreach (FieldInfo Attr in ParametersAttrs)
                    if (Attr.Name.StartsWith("ss"))
                    { something here
well, the brain is on weekend-mode still.

since we no longer have a record, I need to skip the first 2 lines and use parameters directly.
for structures at least...

Hi there,

If I'm not mistaken, "simple records", don't have an intermediate structure, so this FieldInfo ParametersBaseStruct = parameters.GetType().GetFields()[0]; is not needed. It is still needed for records, though.

Also, if I'm not mistaken, in OS9 a "simple record" is either a structure or a single Entity. You only get a Record when you choose the Record data type from the type editor.

There's an extension in the Offline Apps component that uses reflection for records and has been updated for the latest platform version. You may want to check its code.

Edit: you beat me to the answer :D