Open calebho opened 1 year ago
After creating a failing test / repro for this bug and digging into it a bit deeper this seems to behave up to spec.
Here is a runnable sample in sharplab.
Using %A+0
works because it allows access to the private structure of the record as stated in the documentation.
Using %A0
on the other hand only has access to the public structure. Even calling FSharpType.IsRecord(...)
returns false
for private record types. This means we fallback to the ToString
implementation of the instance type.
I think we end up calling this function with BindingFlags.Public
except when a +
is included in the format specifier then we use indingFlags.Public ||| BindingFlags.NonPublic
instead.
Please provide a succinct description of the issue.
Repro steps
Provide the steps required to reproduce the problem:
Script:
Run with:
dotnet fsi Repro.fsx
Expected behavior
The documentation states,
No fields of
priv
are embedded strings containing line breaks, therefore its string representation should be one line.Actual behavior The second group of prints, i.e. "private without '+'", spans more than one line:
Known workarounds
Add
+
to the format string.Related information
Provide any related information (optional):