Skip to content

Commit a88d7c7

Browse files
committed
Fix bug where string print overrides wouldn't be used
1 parent 937c9cc commit a88d7c7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Src/FastData.Generator/Framework/Definitions/StringTypeDef.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ public class StringTypeDef : ITypeDef<string>
88
public StringTypeDef(string name, Func<string, string>? print = null)
99
{
1010
Name = name;
11-
Print = print ?? (static x => $"\"{x}\"");
11+
12+
if (print != null)
13+
{
14+
Print = print;
15+
PrintObj = x => print(x.ToString());
16+
}
17+
else
18+
{
19+
Print = static x => $"\"{x}\"";
20+
PrintObj = static x => $"\"{x}\"";
21+
}
1222
}
1323

1424
public DataType DataType => DataType.String;
1525
public string Name { get; }
16-
public Func<object, string> PrintObj => x => $"\"{x}\"";
26+
public Func<object, string> PrintObj { get; }
1727
public Func<string, string> Print { get; }
1828
}

0 commit comments

Comments
 (0)