From 023b54a2d4a82c6b5996fc67f55b83138de64f08 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 17 Jul 2023 16:52:57 -0400 Subject: [PATCH] Enable CA1863 (Use 'CompositeFormat') as suggestion (#89029) I ran it over runtime, and the only things flagged were for exceptional cases where it's not worth using. Rather than a bunch of suppressions, I'm just enabling it as info-level. --- eng/CodeAnalysis.src.globalconfig | 3 +++ eng/CodeAnalysis.test.globalconfig | 3 +++ src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index 36a3ff9..de0d6e8 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -477,6 +477,9 @@ dotnet_diagnostic.CA1861.severity = warning # CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons dotnet_diagnostic.CA1862.severity = warning +# CA1863: Use 'CompositeFormat' +dotnet_diagnostic.CA1863.severity = suggestion + # CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method dotnet_diagnostic.CA1864.severity = warning diff --git a/eng/CodeAnalysis.test.globalconfig b/eng/CodeAnalysis.test.globalconfig index d884d9f..3312010 100644 --- a/eng/CodeAnalysis.test.globalconfig +++ b/eng/CodeAnalysis.test.globalconfig @@ -474,6 +474,9 @@ dotnet_diagnostic.CA1861.severity = none # CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons dotnet_diagnostic.CA1862.severity = none +# CA1863: Use 'CompositeFormat' +dotnet_diagnostic.CA1863.severity = none + # CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method dotnet_diagnostic.CA1864.severity = none diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index b56d32a..959489b 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -1895,8 +1895,8 @@ namespace System else if (!declaredType.IsAssignableFrom(reflectedType)) { // declaredType is not Array, not generic, and not assignable from reflectedType - throw new ArgumentException(string.Format( - CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, + throw new ArgumentException(SR.Format( + SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } } -- 2.7.4