diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/TextFieldParser.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/TextFieldParser.vb
index 77219110807c4..d97358dcd5a5b 100644
--- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/TextFieldParser.vb
+++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/TextFieldParser.vb
@@ -375,7 +375,7 @@ Namespace Microsoft.VisualBasic.FileIO
Public Function PeekChars(ByVal numberOfChars As Integer) As String
If numberOfChars <= 0 Then
- Throw GetArgumentExceptionWithArgName("numberOfChars", SR.TextFieldParser_NumberOfCharsMustBePositive, "numberOfChars")
+ Throw GetArgumentExceptionWithArgName("numberOfChars", SR.TextFieldParser_NumberOfCharsMustBePositive)
End If
If m_Reader Is Nothing Or m_Buffer Is Nothing Then
@@ -1151,7 +1151,7 @@ Namespace Microsoft.VisualBasic.FileIO
Dim Bound As Integer = Widths.Length - 1
For i As Integer = 0 To Bound - 1
If Widths(i) < 1 Then
- Throw GetArgumentExceptionWithArgName("FieldWidths", SR.TextFieldParser_FieldWidthsMustPositive, "FieldWidths")
+ Throw GetArgumentExceptionWithArgName("FieldWidths", SR.TextFieldParser_FieldWidthsMustPositive)
End If
Next
End Sub
@@ -1163,11 +1163,11 @@ Namespace Microsoft.VisualBasic.FileIO
'''
Private Sub ValidateAndEscapeDelimiters()
If m_Delimiters Is Nothing Then
- Throw GetArgumentExceptionWithArgName("Delimiters", SR.TextFieldParser_DelimitersNothing, "Delimiters")
+ Throw GetArgumentExceptionWithArgName("Delimiters", SR.TextFieldParser_DelimitersNothing)
End If
If m_Delimiters.Length = 0 Then
- Throw GetArgumentExceptionWithArgName("Delimiters", SR.TextFieldParser_DelimitersNothing, "Delimiters")
+ Throw GetArgumentExceptionWithArgName("Delimiters", SR.TextFieldParser_DelimitersNothing)
End If
Dim Length As Integer = m_Delimiters.Length
diff --git a/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/Registry.cs b/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/Registry.cs
index 56cbc26afe977..49eeecff31ab0 100644
--- a/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/Registry.cs
+++ b/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/Registry.cs
@@ -64,7 +64,7 @@ private static RegistryKey GetBaseKeyFromKeyName(string keyName, out string subK
return baseKey;
}
- throw new ArgumentException(SR.Format(SR.Arg_RegInvalidKeyName, nameof(keyName)), nameof(keyName));
+ throw new ArgumentException(SR.Arg_RegInvalidKeyName, nameof(keyName));
}
public static object? GetValue(string keyName, string? valueName, object? defaultValue)
diff --git a/src/libraries/Microsoft.Win32.Registry/src/System/Security/AccessControl/RegistrySecurity.Windows.cs b/src/libraries/Microsoft.Win32.Registry/src/System/Security/AccessControl/RegistrySecurity.Windows.cs
index f5ff293848ffa..f16e03965ed18 100644
--- a/src/libraries/Microsoft.Win32.Registry/src/System/Security/AccessControl/RegistrySecurity.Windows.cs
+++ b/src/libraries/Microsoft.Win32.Registry/src/System/Security/AccessControl/RegistrySecurity.Windows.cs
@@ -19,7 +19,7 @@ public sealed partial class RegistrySecurity : NativeObjectSecurity
break;
case Interop.Errors.ERROR_INVALID_NAME:
- exception = new ArgumentException(SR.Format(SR.Arg_RegInvalidKeyName, nameof(name)));
+ exception = new ArgumentException(SR.Arg_RegInvalidKeyName, nameof(name));
break;
case Interop.Errors.ERROR_INVALID_HANDLE:
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs
index 9037db5175274..9c0393da53ab3 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs
@@ -50,7 +50,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina
if (values.Length != 4)
{
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, "text", text, "x, y, width, height"));
+ throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, text, "x, y, width, height"));
}
return new Rectangle(values[0], values[1], values[2], values[3]);
diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs
index 2ee59adf59464..012a03bcad1c1 100644
--- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs
+++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs
@@ -82,13 +82,13 @@ public void Test_GenerateManifest_InvalidEventSources()
Assert.NotNull(EventSource.GenerateManifest(typeof(Sdt.EventWithReturnEventSource), string.Empty, EventManifestOptions.AllowEventSourceOverride));
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.NegativeEventIdEventSource), string.Empty));
- AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId", "WriteInteger"), e);
+ AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId"), e);
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.NegativeEventIdEventSource), string.Empty, strictOptions));
- AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId", "WriteInteger"), e);
+ AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId"), e);
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.NegativeEventIdEventSource), string.Empty, EventManifestOptions.AllowEventSourceOverride));
- AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId", "WriteInteger"), e);
+ AsserExceptionStringsEqual(() => GetResourceString("EventSource_NeedPositiveId"), e);
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.OutOfRangeKwdEventSource), string.Empty, strictOptions));
AsserExceptionStringsEqual(() => string.Join(Environment.NewLine,
@@ -124,7 +124,7 @@ public void Test_GenerateManifest_InvalidEventSources()
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.EnumKindMismatchEventSource), string.Empty, strictOptions));
AsserExceptionStringsEqual(() => string.Join(Environment.NewLine,
- GetResourceString("EventSource_EnumKindMismatch", "Op1", "EventKeywords", "Opcodes"),
+ GetResourceString("EventSource_EnumKindMismatch", "EventKeywords", "Opcodes"),
GetResourceString("EventSource_UndefinedKeyword", "0x1", "WriteInteger")),
e);
@@ -144,14 +144,14 @@ public void Test_GenerateManifest_InvalidEventSources()
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.EventIdReusedEventSource), string.Empty, strictOptions));
AsserExceptionStringsEqual(() => string.Join(Environment.NewLine,
- GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1, "WriteInteger1"),
+ GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1),
GetResourceString("EventSource_TaskOpcodePairReused", "WriteInteger2", 1, "WriteInteger1", 1)),
e);
e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.EventIdReusedEventSource), string.Empty, strictOptions));
AsserExceptionStringsEqual(() => string.Join(Environment.NewLine,
- GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1, "WriteInteger1"),
+ GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1),
GetResourceString("EventSource_TaskOpcodePairReused", "WriteInteger2", 1, "WriteInteger1", 1)),
e);
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
index 445d7c72c6dd4..098830cbf4a61 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
@@ -83,7 +83,6 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
}
else {
throw new ArgumentException(SR.Format(SR.TextParseFailedFormat,
- "text",
text,
"x, y, width, height"));
}
diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs
index 6171cce6d9a34..78dab30883812 100644
--- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs
+++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs
@@ -55,7 +55,7 @@ public virtual ulong CurrentSize
{
get
{
- throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_CurrentSizeUndefined, nameof(CurrentSize)));
+ throw new InvalidOperationException(SR.IsolatedStorage_CurrentSizeUndefined);
}
}
diff --git a/src/libraries/System.IO.Packaging/src/Resources/Strings.resx b/src/libraries/System.IO.Packaging/src/Resources/Strings.resx
index 668094559fa96..a2ffa3af1ed3d 100644
--- a/src/libraries/System.IO.Packaging/src/Resources/Strings.resx
+++ b/src/libraries/System.IO.Packaging/src/Resources/Strings.resx
@@ -106,7 +106,7 @@
Invalid file format.
- Invalid file format.
+ File '{0}' has an invalid file format.
PackagePart subclass must implement GetContentTypeCore method if passing a null value for the content type when PackagePart object is constructed.
@@ -375,4 +375,4 @@
File contains corrupted data.
-
\ No newline at end of file
+
diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs b/src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs
index 5da904a7c6f9d..a0127f539bc6c 100644
--- a/src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs
+++ b/src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs
@@ -47,7 +47,7 @@ public static IPHostEntry GetHostEntry(IPAddress address)
if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(address, $"Invalid address '{address}'");
- throw new ArgumentException(SR.Format(SR.net_invalid_ip_addr, nameof(address)));
+ throw new ArgumentException(SR.net_invalid_ip_addr, nameof(address));
}
IPHostEntry ipHostEntry = GetHostEntryCore(address, AddressFamily.Unspecified);
@@ -81,7 +81,7 @@ public static IPHostEntry GetHostEntry(string hostNameOrAddress, AddressFamily f
if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(address, $"Invalid address '{address}'");
- throw new ArgumentException(SR.Format(SR.net_invalid_ip_addr, nameof(hostNameOrAddress)));
+ throw new ArgumentException(SR.net_invalid_ip_addr, nameof(hostNameOrAddress));
}
ipHostEntry = GetHostEntryCore(address, family);
@@ -207,7 +207,7 @@ public static IPAddress[] GetHostAddresses(string hostNameOrAddress, AddressFami
if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(address, $"Invalid address '{address}'");
- throw new ArgumentException(SR.Format(SR.net_invalid_ip_addr, nameof(hostNameOrAddress)));
+ throw new ArgumentException(SR.net_invalid_ip_addr, nameof(hostNameOrAddress));
}
addresses = (family == AddressFamily.Unspecified || address.AddressFamily == family) ? new IPAddress[] { address } : Array.Empty();
diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
index 6c79043631eb7..faf0d9f204c7c 100644
--- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
+++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
@@ -153,7 +153,7 @@ public IList>? BufferList
if (!_buffer.Equals(default))
{
// Can't have both set
- throw new ArgumentException(SR.Format(SR.net_ambiguousbuffers, nameof(Buffer)));
+ throw new ArgumentException(SR.net_ambiguousbuffers);
}
// Copy the user-provided list into our internal buffer list,
@@ -358,7 +358,7 @@ public void SetBuffer(byte[]? buffer, int offset, int count)
// Can't have both Buffer and BufferList.
if (_bufferList != null)
{
- throw new ArgumentException(SR.Format(SR.net_ambiguousbuffers, nameof(BufferList)));
+ throw new ArgumentException(SR.net_ambiguousbuffers);
}
// Offset and count can't be negative and the
@@ -391,7 +391,7 @@ public void SetBuffer(Memory buffer)
{
if (buffer.Length != 0 && _bufferList != null)
{
- throw new ArgumentException(SR.Format(SR.net_ambiguousbuffers, nameof(BufferList)));
+ throw new ArgumentException(SR.net_ambiguousbuffers);
}
_buffer = buffer;
@@ -559,7 +559,7 @@ internal void StartOperationAccept()
// Caller specified a buffer - see if it is large enough
if (_count < _acceptAddressBufferCount)
{
- throw new ArgumentException(SR.Format(SR.net_buffercounttoosmall, nameof(Count)));
+ throw new ArgumentException(SR.net_buffercounttoosmall, nameof(Count));
}
}
else
diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
index 01b9cdb3c737a..d311cd0c94bbd 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
@@ -260,7 +260,7 @@ public Hashtable(int capacity, float loadFactor)
if (capacity < 0)
throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum);
if (!(loadFactor >= 0.1f && loadFactor <= 1.0f))
- throw new ArgumentOutOfRangeException(nameof(loadFactor), SR.Format(SR.ArgumentOutOfRange_HashtableLoadFactor, .1, 1.0));
+ throw new ArgumentOutOfRangeException(nameof(loadFactor), SR.ArgumentOutOfRange_HashtableLoadFactor);
// Based on perf work, .72 is the optimal load factor for this table.
_loadFactor = 0.72f * loadFactor;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
index f8d6e9c6ff114..b54a5a50ba62e 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
@@ -3280,7 +3280,7 @@ private static bool AttributeTypeNamesMatch(Type attributeType, Type reflectedAt
}
else if (eventAttribute.EventId <= 0)
{
- manifest.ManifestError(SR.Format(SR.EventSource_NeedPositiveId, method.Name), true);
+ manifest.ManifestError(SR.EventSource_NeedPositiveId, true);
continue; // don't validate anything else for this event
}
if (method.Name.LastIndexOf('.') >= 0)
@@ -3501,7 +3501,7 @@ private static void AddProviderEnumKind(ManifestBuilder manifest, FieldInfo stat
#endif
return;
Error:
- manifest.ManifestError(SR.Format(SR.EventSource_EnumKindMismatch, staticField.Name, staticField.FieldType.Name, providerEnumKind));
+ manifest.ManifestError(SR.Format(SR.EventSource_EnumKindMismatch, staticField.FieldType.Name, providerEnumKind));
}
// Helper used by code:CreateManifestAndDescriptors to add a code:EventData descriptor for a method
@@ -3630,7 +3630,7 @@ private static void DebugCheckEvent(ref Dictionary? eventsByName
if (evtId < eventData.Length && eventData[evtId].Descriptor.EventId != 0)
{
- manifest.ManifestError(SR.Format(SR.EventSource_EventIdReused, evtName, evtId, eventData[evtId].Name), true);
+ manifest.ManifestError(SR.Format(SR.EventSource_EventIdReused, evtName, evtId), true);
}
// We give a task to things if they don't have one.
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryAccessor.cs b/src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryAccessor.cs
index 0e53df433e78c..78d0dab488a56 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryAccessor.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryAccessor.cs
@@ -319,7 +319,7 @@ public void Read(long position, out T structure) where T : struct
}
else
{
- throw new ArgumentException(SR.Format(SR.Argument_NotEnoughBytesToRead, typeof(T)), nameof(position));
+ throw new ArgumentException(SR.Argument_NotEnoughBytesToRead, nameof(position));
}
}
@@ -561,7 +561,7 @@ public void Write(long position, ref T structure) where T : struct
}
else
{
- throw new ArgumentException(SR.Format(SR.Argument_NotEnoughBytesToWrite, typeof(T)), nameof(position));
+ throw new ArgumentException(SR.Argument_NotEnoughBytesToWrite, nameof(position));
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Random.cs b/src/libraries/System.Private.CoreLib/src/System/Random.cs
index 05766c724d267..9107044882333 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Random.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Random.cs
@@ -192,7 +192,7 @@ protected virtual double Sample()
}
private static void ThrowMaxValueMustBeNonNegative() =>
- throw new ArgumentOutOfRangeException("maxValue", SR.Format(SR.ArgumentOutOfRange_NeedNonNegNum, "maxValue"));
+ throw new ArgumentOutOfRangeException("maxValue", SR.ArgumentOutOfRange_NeedNonNegNum);
private static void ThrowMinMaxValueSwapped() =>
throw new ArgumentOutOfRangeException("minValue", SR.Format(SR.Argument_MinMaxValue, "minValue", "maxValue"));
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderReplacementFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderReplacementFallback.cs
index 8f769f1c45bca..34270ba3c30ad 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderReplacementFallback.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderReplacementFallback.cs
@@ -57,7 +57,7 @@ public DecoderReplacementFallback(string replacement)
break;
}
if (bFoundHigh)
- throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement)));
+ throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement));
_strDefault = replacement;
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderReplacementFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderReplacementFallback.cs
index 5c93f4cc2cdb7..709695ce36dd1 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderReplacementFallback.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderReplacementFallback.cs
@@ -58,7 +58,7 @@ public EncoderReplacementFallback(string replacement)
break;
}
if (bFoundHigh)
- throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement)));
+ throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement));
_strDefault = replacement;
}
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs
index 9f561b2554e00..6c320a7295bcd 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs
@@ -1234,7 +1234,7 @@ public void LoadGeneric12(InputType inputType, ReaderType readerType, TransformT
}
catch (System.InvalidOperationException e2)
{
- CheckExpectedError(e2, "system.xml", "Xslt_NoStylesheetLoaded", new string[] { "IDontExist.xsl" });
+ CheckExpectedError(e2, "system.xml", "Xslt_NoStylesheetLoaded", new string[] { "" });
return;
}
}
diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs
index 302a6167c5563..abd9cf514babf 100644
--- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs
+++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs
@@ -190,7 +190,7 @@ public string GetDocumentName(DocumentNameBlobHandle handle)
int separator = blobReader.ReadByte();
if (separator > 0x7f)
{
- throw new BadImageFormatException(SR.Format(SR.InvalidDocumentName, separator));
+ throw new BadImageFormatException(SR.InvalidDocumentName);
}
var pooledBuilder = PooledStringBuilder.GetInstance();
diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
index 2d7395e2e83dd..79d11ebe76203 100644
--- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
+++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
@@ -310,7 +310,7 @@ internal static bool TryValidateParseStyleInteger(NumberStyles style, [NotNullWh
// Check for undefined flags
if ((style & InvalidNumberStyles) != 0)
{
- e = new ArgumentException(SR.Format(SR.Argument_InvalidNumberStyles, nameof(style)));
+ e = new ArgumentException(SR.Argument_InvalidNumberStyles, nameof(style));
return false;
}
if ((style & NumberStyles.AllowHexSpecifier) != 0)
diff --git a/src/libraries/System.Security.Cryptography.Cng/src/Resources/Strings.resx b/src/libraries/System.Security.Cryptography.Cng/src/Resources/Strings.resx
index 4c99946a673e8..4577d05e6187c 100644
--- a/src/libraries/System.Security.Cryptography.Cng/src/Resources/Strings.resx
+++ b/src/libraries/System.Security.Cryptography.Cng/src/Resources/Strings.resx
@@ -178,7 +178,7 @@
The specified curve '{0}' or its parameters are not valid for this platform.
- The specified Oid is not valid. The Oid.FriendlyName or Oid.Value property must be set.
+ The specified Oid ({0}) is not valid. The Oid.FriendlyName or Oid.Value property must be set.
Specified initialization vector (IV) does not match the block size for this algorithm.
diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs
index ce73894fb36e0..cda387503b0f2 100644
--- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs
+++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs
@@ -210,7 +210,7 @@ public string UniqueKeyContainerName
{
if (throwOnNotFound)
{
- throw new CryptographicException(SR.Format(SR.Cryptography_CSP_NotFound, "Error"));
+ throw new CryptographicException(SR.Cryptography_CSP_NotFound);
}
return null;
@@ -243,7 +243,7 @@ private object ReadDeviceParameterVerifyContext(int keyParam)
{
if (hr != CapiHelper.S_OK)
{
- throw new CryptographicException(SR.Format(SR.Cryptography_CSP_NotFound, "Error"));
+ throw new CryptographicException(SR.Cryptography_CSP_NotFound);
}
object retVal = CapiHelper.GetProviderParameter(safeProvHandle, parameters.KeyNumber, keyParam);
diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs
index dbefadab57334..7260b772f46ce 100644
--- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs
+++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs
@@ -117,13 +117,13 @@ internal bool Build(X509Certificate2 certificate, bool throwOnException)
if (_chainPolicy != null && _chainPolicy.CustomTrustStore != null)
{
if (_chainPolicy.TrustMode == X509ChainTrustMode.System && _chainPolicy.CustomTrustStore.Count > 0)
- throw new CryptographicException(SR.Cryptography_CustomTrustCertsInSystemMode, nameof(_chainPolicy.TrustMode));
+ throw new CryptographicException(SR.Cryptography_CustomTrustCertsInSystemMode);
foreach (X509Certificate2 customCertificate in _chainPolicy.CustomTrustStore)
{
if (customCertificate == null || customCertificate.Handle == IntPtr.Zero)
{
- throw new CryptographicException(SR.Cryptography_InvalidTrustCertificate, nameof(_chainPolicy.CustomTrustStore));
+ throw new CryptographicException(SR.Cryptography_InvalidTrustCertificate);
}
}
}
diff --git a/src/libraries/System.Security.Cryptography/src/Resources/Strings.resx b/src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
index 84a24a8fc9ef4..dc30b357b0b38 100644
--- a/src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
+++ b/src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
@@ -205,7 +205,7 @@
The specified key parameters are not valid. Q.X and Q.Y, or D, must be specified. Q.X, Q.Y must be the same length. If D is specified it must be the same length as Q.X and Q.Y if also specified for named curves or the same length as Order for explicit curves.
- The specified Oid is not valid. The Oid.FriendlyName or Oid.Value property must be set.
+ The specified Oid ({0}) is not valid. The Oid.FriendlyName or Oid.Value property must be set.
The specified DSA parameters are not valid; P, G and Y must be the same length (the key size).
diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECCurve.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECCurve.cs
index a14e816f799df..5876e483bcb6d 100644
--- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECCurve.cs
+++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECCurve.cs
@@ -79,7 +79,7 @@ private set
throw new ArgumentNullException(nameof(Oid));
if (string.IsNullOrEmpty(value.Value) && string.IsNullOrEmpty(value.FriendlyName))
- throw new ArgumentException(SR.Cryptography_InvalidCurveOid);
+ throw new ArgumentException(SR.Format(SR.Cryptography_InvalidCurveOid, value.Value));
_oid = value;
}
@@ -197,7 +197,7 @@ public void Validate()
if (Oid == null ||
(string.IsNullOrEmpty(Oid.FriendlyName) && string.IsNullOrEmpty(Oid.Value)))
{
- throw new CryptographicException(SR.Cryptography_InvalidCurveOid);
+ throw new CryptographicException(SR.Format(SR.Cryptography_InvalidCurveOid, Oid?.Value));
}
}
else if (IsExplicit)
diff --git a/src/libraries/System.Text.Encoding/tests/Fallback/DecoderReplacementFallbackTests.cs b/src/libraries/System.Text.Encoding/tests/Fallback/DecoderReplacementFallbackTests.cs
index 51d3f2d074e72..7bb51d8a22dd8 100644
--- a/src/libraries/System.Text.Encoding/tests/Fallback/DecoderReplacementFallbackTests.cs
+++ b/src/libraries/System.Text.Encoding/tests/Fallback/DecoderReplacementFallbackTests.cs
@@ -36,12 +36,12 @@ public void Ctor_Invalid()
AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback(null));
// Invalid surrogate pair
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("\uD800"));
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("\uD800a"));
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("\uDC00"));
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("a\uDC00"));
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("\uDC00\uDC00"));
- AssertExtensions.Throws(null, () => new DecoderReplacementFallback("\uD800\uD800"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("\uD800"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("\uD800a"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("\uDC00"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("a\uDC00"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("\uDC00\uDC00"));
+ AssertExtensions.Throws("replacement", () => new DecoderReplacementFallback("\uD800\uD800"));
}
public static IEnumerable