Skip to content

Commit 3ee2816

Browse files
committed
Fix for string rendering
1 parent 248433a commit 3ee2816

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Shared/Util/Functions.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ public static (bool isLiteral, string repr) TryRenderLiteral(object o, string la
106106
/// <summary>Returns a string representation of the value, which may or may not be a valid literal in the language</summary>
107107
public static string StringValue(object o, string language) {
108108
var (isLiteral, repr) = TryRenderLiteral(o, language);
109-
var hasDeclaredToString = o.GetType().GetMethods().Any(x => {
110-
if (x.Name != "ToString") { return false; }
111-
if (x.GetParameters().Any()) { return false; }
112-
if (x.DeclaringType == typeof(object)) { return false; }
113-
if (x.DeclaringType.InheritsFromOrImplements<EnumerableQuery>()) { return false; } // EnumerableQuery implements its own ToString which we don't want to use
114-
return true;
115-
});
116-
if (hasDeclaredToString) { return o.ToString(); }
109+
if (!isLiteral) {
110+
var hasDeclaredToString = o.GetType().GetMethods().Any(x => {
111+
if (x.Name != "ToString") { return false; }
112+
if (x.GetParameters().Any()) { return false; }
113+
if (x.DeclaringType == typeof(object)) { return false; }
114+
if (x.DeclaringType.InheritsFromOrImplements<EnumerableQuery>()) { return false; } // EnumerableQuery implements its own ToString which we don't want to use
115+
return true;
116+
});
117+
if (hasDeclaredToString) { return o.ToString(); }
118+
}
117119
return repr;
118120
}
119121

0 commit comments

Comments
 (0)