diff --git a/src/ObjCRuntime/Runtime.CoreCLR.cs b/src/ObjCRuntime/Runtime.CoreCLR.cs index 2f8a68bff965..3beaa11122e1 100644 --- a/src/ObjCRuntime/Runtime.CoreCLR.cs +++ b/src/ObjCRuntime/Runtime.CoreCLR.cs @@ -106,11 +106,13 @@ static void log_coreclr_render (string message, params object[] argumentsToRende arg = $"{inativeobj.Handle.ToString ()} ({obj.GetType ()})"; } else { var toString = obj.ToString (); + // Print one line, and at most 256 characters. + var strLength = Math.Min (256, toString.Length); var eol = toString.IndexOf ('\n'); - if (eol != -1) - toString = toString.Substring (0, eol - 1) + " [...]"; - if (toString.Length > 256) - toString = toString.Substring (0, 256) + " [...]"; + if (eol != -1 && eol < strLength) + strLength = eol; + if (strLength != toString.Length) + toString = toString.Substring (0, strLength) + " [...]"; arg = $"{toString} ({obj.GetType ()})"; }