As you say, StructuredFormatDisplayAttribute only works for members that are compiled as properties (including standard properties, same assemblies, but not extensions). Under the cover, it is accessed using reflection (as you can see, it can also be private):
let getProperty (obj: obj) name = let ty = obj.GetType() ty.InvokeMember(name, (BindingFlags.GetProperty ||| BindingFlags.Instance ||| BindingFlags.Public ||| BindingFlags.NonPublic), null, obj, [| |],CultureInfo.InvariantCulture)
If you need this for debugging purposes, the DebuggerTypeProxy attribute may be an alternative (see the MSDN documentation ). This allows you to replace the original type with a proxy type, which is used to display the type in the debugger. (But I think that the attribute should still be placed in the actual type definition, and not on the extension.)
source share