This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit fcc905895c1657a55b1adfa224b271715949b408 Author: Shad Storhaug <[email protected]> AuthorDate: Mon Nov 2 01:38:13 2020 +0700 Lucene.Net.Diagnostics.Debugging: Use J2N StringFormatter to automatically format arrays and IStructuralFormattable collections --- src/Lucene.Net/Support/Diagnostics/Debugging.cs | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Lucene.Net/Support/Diagnostics/Debugging.cs b/src/Lucene.Net/Support/Diagnostics/Debugging.cs index 428fe62..33b70e2 100644 --- a/src/Lucene.Net/Support/Diagnostics/Debugging.cs +++ b/src/Lucene.Net/Support/Diagnostics/Debugging.cs @@ -1,5 +1,5 @@ +using J2N.Text; using Lucene.Net.Util; -using System; using System.Runtime.CompilerServices; namespace Lucene.Net.Diagnostics @@ -56,7 +56,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0>(bool condition, string messageToFormat, T0 p0) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0)); } /// <summary> @@ -68,7 +69,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1>(bool condition, string messageToFormat, T0 p0, T1 p1) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1)); } /// <summary> @@ -80,7 +82,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2)); } /// <summary> @@ -92,7 +95,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2, T3>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2, T3 p3) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2, p3)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2, p3)); } /// <summary> @@ -104,7 +108,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2, T3, T4>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2, p3, p4)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2, p3, p4)); } /// <summary> @@ -116,7 +121,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2, T3, T4, T5>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2, p3, p4, p5)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2, p3, p4, p5)); } /// <summary> @@ -128,7 +134,8 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2, T3, T4, T5, T6>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2, p3, p4, p5, p6)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2, p3, p4, p5, p6)); } /// <summary> @@ -140,13 +147,15 @@ namespace Lucene.Net.Diagnostics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert<T0, T1, T2, T3, T4, T5, T6, T7>(bool condition, string messageToFormat, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7) { - if (AssertsEnabled && !condition) throw new AssertionException(string.Format(messageToFormat, p0, p1, p2, p3, p4, p5, p6, p7)); + if (AssertsEnabled && !condition) + throw new AssertionException(string.Format(StringFormatter.InvariantCulture, messageToFormat, p0, p1, p2, p3, p4, p5, p6, p7)); } /// <summary> /// Checks for a condition; if the <paramref name="condition"/> is <c>false</c>, throws an <see cref="AssertionException"/> with the given message. /// <para/> - /// IMPORTANT: If you need to use string concatenation when building the message, use <see cref="Assert(bool, Func{string})"/> for better performance. + /// IMPORTANT: If you need to use string concatenation when building the message, use an overload of + /// <see cref="Assert{T0}(bool, string, T0)"/> for better performance. /// </summary> /// <param name="condition">The conditional expression to evaluate. If the condition is <c>true</c>, no exception is thrown.</param> /// <param name="message">The message to use.</param>
