diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs index bb5f8b675a08d..412c00ae19fd9 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs @@ -34,7 +34,7 @@ public HostAbortedException() : base(SR.HostAbortedExceptionMessage) { } /// The caller of this constructor is required to ensure that this string has been localized for the /// current system culture. /// - public HostAbortedException(string? message) : base(message) { } + public HostAbortedException(string? message) : base(message ?? SR.HostAbortedExceptionMessage) { } /// /// Initializes a new instance of the class @@ -52,6 +52,6 @@ public HostAbortedException(string? message) : base(message) { } /// The caller of this constructor is required to ensure that this string has been localized for the /// current system culture. /// - public HostAbortedException(string? message, Exception? innerException) : base(message, innerException) { } + public HostAbortedException(string? message, Exception? innerException) : base(message ?? SR.HostAbortedExceptionMessage, innerException) { } } } diff --git a/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/CompositionFailedException.cs b/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/CompositionFailedException.cs index e461bca158288..a36935db790e6 100644 --- a/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/CompositionFailedException.cs +++ b/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/CompositionFailedException.cs @@ -22,7 +22,7 @@ public CompositionFailedException() /// /// The exception message. public CompositionFailedException(string message) - : base(message) + : base(message ?? SR.CompositionFailedDefaultExceptionMessage) { } /// @@ -31,7 +31,7 @@ public CompositionFailedException(string message) /// The exception message. /// The inner exception. public CompositionFailedException(string message, Exception innerException) - : base(message, innerException) + : base(message ?? SR.CompositionFailedDefaultExceptionMessage, innerException) { } } } diff --git a/src/libraries/System.Configuration.ConfigurationManager/tests/Mono/ConfigurationErrorsExceptionTest.cs b/src/libraries/System.Configuration.ConfigurationManager/tests/Mono/ConfigurationErrorsExceptionTest.cs index 147265c36adb7..e6a7e7e8ceead 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/tests/Mono/ConfigurationErrorsExceptionTest.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/tests/Mono/ConfigurationErrorsExceptionTest.cs @@ -46,11 +46,6 @@ public void Constructor1() ConfigurationErrorsException cee = new ConfigurationErrorsException(); Assert.NotNull(cee.BareMessage); - // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi - // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf - // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po - Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape(typeof(ConfigurationErrorsException).FullName) + @"[\p{Pf}\p{Po}]", cee.BareMessage); - Assert.NotNull(cee.Data); Assert.Equal(0, cee.Data.Count); Assert.Null(cee.Filename); diff --git a/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs b/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs index e99408d956790..855e2b4c0abdc 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs @@ -21,12 +21,12 @@ public DBConcurrencyException(string? message) : this(message, null) { } - public DBConcurrencyException(string? message, Exception? inner) : base(message, inner) + public DBConcurrencyException(string? message, Exception? inner) : base(message ?? SR.ADP_DBConcurrencyExceptionMessage, inner) { HResult = HResults.DBConcurrency; } - public DBConcurrencyException(string? message, Exception? inner, DataRow[]? dataRows) : base(message, inner) + public DBConcurrencyException(string? message, Exception? inner, DataRow[]? dataRows) : base(message ?? SR.ADP_DBConcurrencyExceptionMessage, inner) { HResult = HResults.DBConcurrency; _dataRows = dataRows; diff --git a/src/libraries/System.Data.Common/src/System/Data/DataException.cs b/src/libraries/System.Data.Common/src/System/Data/DataException.cs index 556dcba9ae9fe..a63ca2b7721a0 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataException.cs @@ -23,12 +23,12 @@ public DataException() : base(SR.DataSet_DefaultDataException) HResult = HResults.Data; } - public DataException(string? s) : base(s) + public DataException(string? s) : base(s ?? SR.DataSet_DefaultDataException) { HResult = HResults.Data; } - public DataException(string? s, Exception? innerException) : base(s, innerException) { } + public DataException(string? s, Exception? innerException) : base(s ?? SR.DataSet_DefaultDataException, innerException) { } }; [Serializable] @@ -46,12 +46,12 @@ public ConstraintException() : base(SR.DataSet_DefaultConstraintException) HResult = HResults.DataConstraint; } - public ConstraintException(string? s) : base(s) + public ConstraintException(string? s) : base(s ?? SR.DataSet_DefaultConstraintException) { HResult = HResults.DataConstraint; } - public ConstraintException(string? message, Exception? innerException) : base(message, innerException) + public ConstraintException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultConstraintException, innerException) { HResult = HResults.DataConstraint; } @@ -78,12 +78,12 @@ public DeletedRowInaccessibleException() : base(SR.DataSet_DefaultDeletedRowInac /// /// Initializes a new instance of the class with the specified string. /// - public DeletedRowInaccessibleException(string? s) : base(s) + public DeletedRowInaccessibleException(string? s) : base(s ?? SR.DataSet_DefaultDeletedRowInaccessibleException) { HResult = HResults.DataDeletedRowInaccessible; } - public DeletedRowInaccessibleException(string? message, Exception? innerException) : base(message, innerException) + public DeletedRowInaccessibleException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultDeletedRowInaccessibleException, innerException) { HResult = HResults.DataDeletedRowInaccessible; } @@ -104,12 +104,12 @@ public DuplicateNameException() : base(SR.DataSet_DefaultDuplicateNameException) HResult = HResults.DataDuplicateName; } - public DuplicateNameException(string? s) : base(s) + public DuplicateNameException(string? s) : base(s ?? SR.DataSet_DefaultDuplicateNameException) { HResult = HResults.DataDuplicateName; } - public DuplicateNameException(string? message, Exception? innerException) : base(message, innerException) + public DuplicateNameException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultDuplicateNameException, innerException) { HResult = HResults.DataDuplicateName; } @@ -130,12 +130,12 @@ public InRowChangingEventException() : base(SR.DataSet_DefaultInRowChangingEvent HResult = HResults.DataInRowChangingEvent; } - public InRowChangingEventException(string? s) : base(s) + public InRowChangingEventException(string? s) : base(s ?? SR.DataSet_DefaultInRowChangingEventException) { HResult = HResults.DataInRowChangingEvent; } - public InRowChangingEventException(string? message, Exception? innerException) : base(message, innerException) + public InRowChangingEventException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultInRowChangingEventException, innerException) { HResult = HResults.DataInRowChangingEvent; } @@ -156,12 +156,12 @@ public InvalidConstraintException() : base(SR.DataSet_DefaultInvalidConstraintEx HResult = HResults.DataInvalidConstraint; } - public InvalidConstraintException(string? s) : base(s) + public InvalidConstraintException(string? s) : base(s ?? SR.DataSet_DefaultInvalidConstraintException) { HResult = HResults.DataInvalidConstraint; } - public InvalidConstraintException(string? message, Exception? innerException) : base(message, innerException) + public InvalidConstraintException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultInvalidConstraintException, innerException) { HResult = HResults.DataInvalidConstraint; } @@ -182,12 +182,12 @@ public MissingPrimaryKeyException() : base(SR.DataSet_DefaultMissingPrimaryKeyEx HResult = HResults.DataMissingPrimaryKey; } - public MissingPrimaryKeyException(string? s) : base(s) + public MissingPrimaryKeyException(string? s) : base(s ?? SR.DataSet_DefaultMissingPrimaryKeyException) { HResult = HResults.DataMissingPrimaryKey; } - public MissingPrimaryKeyException(string? message, Exception? innerException) : base(message, innerException) + public MissingPrimaryKeyException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultMissingPrimaryKeyException, innerException) { HResult = HResults.DataMissingPrimaryKey; } @@ -208,12 +208,12 @@ public NoNullAllowedException() : base(SR.DataSet_DefaultNoNullAllowedException) HResult = HResults.DataNoNullAllowed; } - public NoNullAllowedException(string? s) : base(s) + public NoNullAllowedException(string? s) : base(s ?? SR.DataSet_DefaultNoNullAllowedException) { HResult = HResults.DataNoNullAllowed; } - public NoNullAllowedException(string? message, Exception? innerException) : base(message, innerException) + public NoNullAllowedException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultNoNullAllowedException, innerException) { HResult = HResults.DataNoNullAllowed; } @@ -234,12 +234,12 @@ public ReadOnlyException() : base(SR.DataSet_DefaultReadOnlyException) HResult = HResults.DataReadOnly; } - public ReadOnlyException(string? s) : base(s) + public ReadOnlyException(string? s) : base(s ?? SR.DataSet_DefaultReadOnlyException) { HResult = HResults.DataReadOnly; } - public ReadOnlyException(string? message, Exception? innerException) : base(message, innerException) + public ReadOnlyException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultReadOnlyException, innerException) { HResult = HResults.DataReadOnly; } @@ -260,12 +260,12 @@ public RowNotInTableException() : base(SR.DataSet_DefaultRowNotInTableException) HResult = HResults.DataRowNotInTable; } - public RowNotInTableException(string? s) : base(s) + public RowNotInTableException(string? s) : base(s ?? SR.DataSet_DefaultRowNotInTableException) { HResult = HResults.DataRowNotInTable; } - public RowNotInTableException(string? message, Exception? innerException) : base(message, innerException) + public RowNotInTableException(string? message, Exception? innerException) : base(message ?? SR.DataSet_DefaultRowNotInTableException, innerException) { HResult = HResults.DataRowNotInTable; } @@ -286,12 +286,12 @@ public VersionNotFoundException() : base(SR.DataSet_DefaultVersionNotFoundExcept HResult = HResults.DataVersionNotFound; } - public VersionNotFoundException(string? s) : base(s) + public VersionNotFoundException(string? s) : base(s ?? (SR.DataSet_DefaultVersionNotFoundException)) { HResult = HResults.DataVersionNotFound; } - public VersionNotFoundException(string? message, Exception? innerException) : base(message, innerException) + public VersionNotFoundException(string? message, Exception? innerException) : base(message ?? (SR.DataSet_DefaultVersionNotFoundException), innerException) { HResult = HResults.DataVersionNotFound; } diff --git a/src/libraries/System.Data.Common/tests/System/Data/DBConcurrencyExceptionTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DBConcurrencyExceptionTest.cs index 47df1abddc6b1..5ea12f0354d4c 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DBConcurrencyExceptionTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DBConcurrencyExceptionTest.cs @@ -35,7 +35,6 @@ public void Constructor1() DBConcurrencyException dbce = new DBConcurrencyException(); Assert.Null(dbce.InnerException); Assert.NotNull(dbce.Message); - Assert.NotNull(dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); } @@ -55,9 +54,7 @@ public void Constructor2() dbce = new DBConcurrencyException(null); Assert.Null(dbce.InnerException); Assert.NotNull(dbce.Message); - Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); Assert.Null(dbce.Row); - Assert.Equal(0, dbce.RowCount); dbce = new DBConcurrencyException(string.Empty); @@ -82,7 +79,7 @@ public void Constructor3() dbce = new DBConcurrencyException(null, inner); Assert.Same(inner, dbce.InnerException); - Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); + Assert.NotNull(dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); @@ -100,7 +97,7 @@ public void Constructor3() dbce = new DBConcurrencyException(null, null); Assert.Null(dbce.InnerException); - Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); + Assert.NotNull(dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); } @@ -126,7 +123,7 @@ public void Constructor4() rows = new DataRow[] { rowB, rowA, null }; dbce = new DBConcurrencyException(null, inner, rows); Assert.Same(inner, dbce.InnerException); - Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); + Assert.NotNull(dbce.Message); Assert.Same(rowB, dbce.Row); Assert.Equal(3, dbce.RowCount); @@ -154,7 +151,7 @@ public void Constructor4() rows = null; dbce = new DBConcurrencyException(null, null, rows); Assert.Null(dbce.InnerException); - Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); + Assert.NotNull(dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); } diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs index b4134d58e9b3e..48235f0cbc1ef 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs @@ -42,11 +42,11 @@ public class DirectoryOperationException : DirectoryException, ISerializable #endif protected DirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } - public DirectoryOperationException() : base() { } + public DirectoryOperationException() : base(SR.DefaultOperationsError) { } - public DirectoryOperationException(string message) : base(message) { } + public DirectoryOperationException(string message) : base(message ?? SR.DefaultOperationsError) { } - public DirectoryOperationException(string message, Exception inner) : base(message, inner) { } + public DirectoryOperationException(string message, Exception inner) : base(message ?? SR.DefaultOperationsError, inner) { } public DirectoryOperationException(DirectoryResponse response) : base(CreateMessage(response, message: null)) @@ -68,7 +68,7 @@ public DirectoryOperationException(DirectoryResponse response, string message, E public DirectoryResponse Response { get; internal set; } - private static string CreateMessage(DirectoryResponse response, string message) + private static string CreateMessage(DirectoryResponse response, string? message) { string result = message ?? SR.DefaultOperationsError; if (!string.IsNullOrEmpty(response?.ErrorMessage)) @@ -93,11 +93,11 @@ public BerConversionException() : base(SR.BerConversionError) { } - public BerConversionException(string message) : base(message) + public BerConversionException(string message) : base(message ?? SR.BerConversionError) { } - public BerConversionException(string message, Exception inner) : base(message, inner) + public BerConversionException(string message, Exception inner) : base(message ?? SR.BerConversionError, inner) { } } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs index b5887f12cc275..85ea36b623f06 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs @@ -87,19 +87,19 @@ public override string Message [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class ActiveDirectoryOperationException : Exception, ISerializable { - public ActiveDirectoryOperationException(string? message, Exception? inner, int errorCode) : base(message, inner) + public ActiveDirectoryOperationException(string? message, Exception? inner, int errorCode) : base(message ?? SR.DSUnknownFailure, inner) { ErrorCode = errorCode; } - public ActiveDirectoryOperationException(string? message, int errorCode) : base(message) + public ActiveDirectoryOperationException(string? message, int errorCode) : base(message ?? SR.DSUnknownFailure) { ErrorCode = errorCode; } - public ActiveDirectoryOperationException(string? message, Exception? inner) : base(message, inner) { } + public ActiveDirectoryOperationException(string? message, Exception? inner) : base(message ?? SR.DSUnknownFailure, inner) { } - public ActiveDirectoryOperationException(string? message) : base(message) { } + public ActiveDirectoryOperationException(string? message) : base(message ?? SR.DSUnknownFailure) { } public ActiveDirectoryOperationException() : base(SR.DSUnknownFailure) { } @@ -205,14 +205,14 @@ public class SyncFromAllServersOperationException : ActiveDirectoryOperationExce { private readonly SyncFromAllServersErrorInformation[]? _errors; - public SyncFromAllServersOperationException(string? message, Exception? inner, SyncFromAllServersErrorInformation[]? errors) : base(message, inner) + public SyncFromAllServersOperationException(string? message, Exception? inner, SyncFromAllServersErrorInformation[]? errors) : base(message ?? SR.DSSyncAllFailure, inner) { _errors = errors; } - public SyncFromAllServersOperationException(string? message, Exception? inner) : base(message, inner) { } + public SyncFromAllServersOperationException(string? message, Exception? inner) : base(message ?? SR.DSSyncAllFailure, inner) { } - public SyncFromAllServersOperationException(string? message) : base(message) { } + public SyncFromAllServersOperationException(string? message) : base(message ?? SR.DSSyncAllFailure) { } public SyncFromAllServersOperationException() : base(SR.DSSyncAllFailure) { } @@ -253,14 +253,14 @@ public override void GetObjectData(SerializationInfo serializationInfo, Streamin [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class ForestTrustCollisionException : ActiveDirectoryOperationException, ISerializable { - public ForestTrustCollisionException(string? message, Exception? inner, ForestTrustRelationshipCollisionCollection? collisions) : base(message, inner) + public ForestTrustCollisionException(string? message, Exception? inner, ForestTrustRelationshipCollisionCollection? collisions) : base(message ?? SR.ForestTrustCollision, inner) { Collisions = collisions; } - public ForestTrustCollisionException(string? message, Exception? inner) : base(message, inner) { } + public ForestTrustCollisionException(string? message, Exception? inner) : base(message ?? SR.ForestTrustCollision, inner) { } - public ForestTrustCollisionException(string? message) : base(message) { } + public ForestTrustCollisionException(string? message) : base(message ?? SR.ForestTrustCollision) { } public ForestTrustCollisionException() : base(SR.ForestTrustCollision) { } diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs b/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs index 1d0873a2ba8c3..42c3ee3126d2d 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs +++ b/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs @@ -18,13 +18,13 @@ public DriveNotFoundException() } public DriveNotFoundException(string? message) - : base(message) + : base(message ?? SR.IO_DriveNotFound) { HResult = HResults.COR_E_DIRECTORYNOTFOUND; } public DriveNotFoundException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.IO_DriveNotFound, innerException) { HResult = HResults.COR_E_DIRECTORYNOTFOUND; } diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs index 7c42d59b68e03..f081411391016 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs @@ -24,13 +24,13 @@ public IsolatedStorageException() } public IsolatedStorageException(string? message) - : base(message) + : base(message ?? SR.IsolatedStorage_Exception) { HResult = COR_E_ISOSTORE; } public IsolatedStorageException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.IsolatedStorage_Exception, inner) { HResult = COR_E_ISOSTORE; } diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs index 6bed53f579637..9946c94badff4 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs @@ -30,7 +30,7 @@ public FileFormatException() /// /// The message that describes the error. public FileFormatException(string? message) - : base(message) + : base(message ?? SR.FileFormatException) { } /// @@ -41,7 +41,7 @@ public FileFormatException(string? message) /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception. public FileFormatException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.FileFormatException, innerException) { } /// @@ -71,7 +71,7 @@ public FileFormatException(Uri? sourceUri) /// The Uri of a file that caused this error. /// The message that describes the error. public FileFormatException(Uri? sourceUri, string? message) - : base(message) + : base(message ?? SR.FileFormatException) { _sourceUri = sourceUri; } @@ -108,7 +108,7 @@ public FileFormatException(Uri? sourceUri, Exception? innerException) /// The message that describes the error. /// The exception that is the cause of the current exception. public FileFormatException(Uri? sourceUri, string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.FileFormatException, innerException) { _sourceUri = sourceUri; } diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs index 4f4c5d5468be1..ccc80dae98f0a 100644 --- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs +++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs @@ -24,7 +24,7 @@ public WebSocketException(WebSocketError error) { } - public WebSocketException(WebSocketError error, string? message) : base(message) + public WebSocketException(WebSocketError error, string? message) : base(message ?? SR.net_WebSockets_Generic) { _webSocketErrorCode = error; } @@ -35,7 +35,7 @@ public WebSocketException(WebSocketError error, Exception? innerException) } public WebSocketException(WebSocketError error, string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.net_WebSockets_Generic, innerException) { _webSocketErrorCode = error; } @@ -67,7 +67,7 @@ public WebSocketException(WebSocketError error, int nativeError) } public WebSocketException(WebSocketError error, int nativeError, string? message) - : base(message) + : base(message ?? SR.net_WebSockets_Generic) { _webSocketErrorCode = error; SetErrorCodeOnError(nativeError); @@ -79,19 +79,19 @@ public WebSocketException(WebSocketError error, int nativeError, Exception? inne } public WebSocketException(WebSocketError error, int nativeError, string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.net_WebSockets_Generic, innerException) { _webSocketErrorCode = error; SetErrorCodeOnError(nativeError); } public WebSocketException(string? message) - : base(message) + : base(message ?? SR.net_WebSockets_Generic) { } public WebSocketException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.net_WebSockets_Generic, innerException) { } diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 53cc0c13d1abb..68969b6453939 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -257,7 +257,7 @@ Must specify property Set or Get or method call for a COM Object. - Error HRESULT E_FAIL has been returned from a call to a COM component. + Unexpected HRESULT has been returned from a call to a COM component. Only one of the following binding flags can be set: BindingFlags.SetProperty, BindingFlags.PutDispProperty, BindingFlags.PutRefDispProperty. diff --git a/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs b/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs index 32b5064d0ddef..80c7db151b13a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs @@ -21,13 +21,13 @@ public AccessViolationException() } public AccessViolationException(string? message) - : base(message) + : base(message ?? SR.Arg_AccessViolationException) { HResult = HResults.E_POINTER; } public AccessViolationException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_AccessViolationException, innerException) { HResult = HResults.E_POINTER; } diff --git a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs index 355b0b66204d9..f9ec9353812d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs @@ -40,7 +40,7 @@ public AggregateException() /// /// The error message that explains the reason for the exception. public AggregateException(string? message) - : base(message) + : base(message ?? SR.AggregateException_ctor_DefaultMessage) { _innerExceptions = Array.Empty(); } @@ -54,7 +54,7 @@ public AggregateException(string? message) /// The argument /// is null. public AggregateException(string? message, Exception innerException) - : base(message, innerException) + : base(message ?? SR.AggregateException_ctor_DefaultMessage, innerException) { ArgumentNullException.ThrowIfNull(innerException); @@ -120,7 +120,7 @@ public AggregateException(string? message, params Exception[] innerExceptions) : } private AggregateException(string? message, Exception[] innerExceptions, bool cloneExceptions) : - base(message, innerExceptions.Length > 0 ? innerExceptions[0] : null) + base(message ?? SR.AggregateException_ctor_DefaultMessage, innerExceptions.Length > 0 ? innerExceptions[0] : null) { _innerExceptions = cloneExceptions ? new Exception[innerExceptions.Length] : innerExceptions; diff --git a/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs b/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs index 9b00bce65beb2..321dd47be488e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs @@ -18,13 +18,13 @@ public AppDomainUnloadedException() } public AppDomainUnloadedException(string? message) - : base(message) + : base(message ?? SR.Arg_AppDomainUnloadedException) { HResult = HResults.COR_E_APPDOMAINUNLOADED; } public AppDomainUnloadedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_AppDomainUnloadedException, innerException) { HResult = HResults.COR_E_APPDOMAINUNLOADED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs index 4bbf0ca545521..b563c12dfa356 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs @@ -31,13 +31,13 @@ public ArgumentNullException(string? paramName) } public ArgumentNullException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.ArgumentNull_Generic, innerException) { HResult = HResults.E_POINTER; } public ArgumentNullException(string? paramName, string? message) - : base(message, paramName) + : base(message ?? SR.ArgumentNull_Generic, paramName) { HResult = HResults.E_POINTER; } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs index b64df585efbfb..9dc65537a66db 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs @@ -34,19 +34,19 @@ public ArgumentOutOfRangeException(string? paramName) } public ArgumentOutOfRangeException(string? paramName, string? message) - : base(message, paramName) + : base(message ?? SR.Arg_ArgumentOutOfRangeException, paramName) { HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } public ArgumentOutOfRangeException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_ArgumentOutOfRangeException, innerException) { HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } public ArgumentOutOfRangeException(string? paramName, object? actualValue, string? message) - : base(message, paramName) + : base(message ?? SR.Arg_ArgumentOutOfRangeException, paramName) { _actualValue = actualValue; HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; diff --git a/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs b/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs index 510a0c412ea10..093222d496c1b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs @@ -28,13 +28,13 @@ public ArithmeticException() // and its ExceptionInfo reference set to null. // public ArithmeticException(string? message) - : base(message) + : base(message ?? SR.Arg_ArithmeticException) { HResult = HResults.COR_E_ARITHMETIC; } public ArithmeticException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_ArithmeticException, innerException) { HResult = HResults.COR_E_ARITHMETIC; } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs index f06701be79206..d1e5f96358ba5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs @@ -28,13 +28,13 @@ public ArrayTypeMismatchException() // and its ExceptionInfo reference set to null. // public ArrayTypeMismatchException(string? message) - : base(message) + : base(message ?? SR.Arg_ArrayTypeMismatchException) { HResult = HResults.COR_E_ARRAYTYPEMISMATCH; } public ArrayTypeMismatchException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_ArrayTypeMismatchException, innerException) { HResult = HResults.COR_E_ARRAYTYPEMISMATCH; } diff --git a/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs b/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs index d23f947639f4d..0f915e1ff1e6e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs @@ -18,13 +18,13 @@ public CannotUnloadAppDomainException() } public CannotUnloadAppDomainException(string? message) - : base(message) + : base(message ?? SR.Arg_CannotUnloadAppDomainException) { HResult = HResults.COR_E_CANNOTUNLOADAPPDOMAIN; } public CannotUnloadAppDomainException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_CannotUnloadAppDomainException, innerException) { HResult = HResults.COR_E_CANNOTUNLOADAPPDOMAIN; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs index f0d34db23b95d..2afb92204427d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs @@ -18,13 +18,13 @@ public KeyNotFoundException() } public KeyNotFoundException(string? message) - : base(message) + : base(message ?? SR.Arg_KeyNotFound) { HResult = HResults.COR_E_KEYNOTFOUND; } public KeyNotFoundException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_KeyNotFound, innerException) { HResult = HResults.COR_E_KEYNOTFOUND; } diff --git a/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs b/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs index 7990c153b8c55..d14fa88d1ab93 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs @@ -21,13 +21,13 @@ public DataMisalignedException() } public DataMisalignedException(string? message) - : base(message) + : base(message ?? SR.Arg_DataMisalignedException) { HResult = HResults.COR_E_DATAMISALIGNED; } public DataMisalignedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_DataMisalignedException, innerException) { HResult = HResults.COR_E_DATAMISALIGNED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs index 29a2a53c92746..2bdacfa3a14ba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs @@ -22,13 +22,13 @@ public EventSourceException() : /// /// Initializes a new instance of the EventSourceException class with a specified error message. /// - public EventSourceException(string? message) : base(message) { } + public EventSourceException(string? message) : base(message ?? SR.EventSource_ListenerWriteFailure) { } /// /// Initializes a new instance of the EventSourceException class with a specified error message /// and a reference to the inner exception that is the cause of this exception. /// - public EventSourceException(string? message, Exception? innerException) : base(message, innerException) { } + public EventSourceException(string? message, Exception? innerException) : base(message ?? SR.EventSource_ListenerWriteFailure, innerException) { } /// /// Initializes a new instance of the EventSourceException class with serialized data. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/UnreachableException.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/UnreachableException.cs index 1b1a22b50995f..c2f94cc2fde02 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/UnreachableException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/UnreachableException.cs @@ -22,7 +22,7 @@ public UnreachableException() /// /// The error message that explains the reason for the exception. public UnreachableException(string? message) - : base(message) + : base(message ?? SR.Arg_UnreachableException) { } @@ -34,7 +34,7 @@ public UnreachableException(string? message) /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception. public UnreachableException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_UnreachableException, innerException) { } } diff --git a/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs b/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs index 33b2853620ba9..350552182dfd6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs @@ -21,13 +21,13 @@ public DivideByZeroException() } public DivideByZeroException(string? message) - : base(message) + : base(message ?? SR.Arg_DivideByZero) { HResult = HResults.COR_E_DIVIDEBYZERO; } public DivideByZeroException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_DivideByZero, innerException) { HResult = HResults.COR_E_DIVIDEBYZERO; } diff --git a/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs index 76e6968e48a58..b0cb6936e6a96 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs @@ -21,13 +21,13 @@ public DllNotFoundException() } public DllNotFoundException(string? message) - : base(message) + : base(message ?? SR.Arg_DllNotFoundException) { HResult = HResults.COR_E_DLLNOTFOUND; } public DllNotFoundException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_DllNotFoundException, inner) { HResult = HResults.COR_E_DLLNOTFOUND; } diff --git a/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs b/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs index f83bde1bdd2a3..aa414d1002f1b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs @@ -29,13 +29,13 @@ public DuplicateWaitObjectException(string? parameterName) } public DuplicateWaitObjectException(string? parameterName, string? message) - : base(message, parameterName) + : base(message ?? SR.Arg_DuplicateWaitObjectException, parameterName) { HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } public DuplicateWaitObjectException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_DuplicateWaitObjectException, innerException) { HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs index 4eac8c07d538d..a0aa9b1208969 100644 --- a/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs @@ -21,13 +21,13 @@ public EntryPointNotFoundException() } public EntryPointNotFoundException(string? message) - : base(message) + : base(message ?? SR.Arg_EntryPointNotFoundException) { HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; } public EntryPointNotFoundException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_EntryPointNotFoundException, inner) { HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; } diff --git a/src/libraries/System.Private.CoreLib/src/System/ExecutionEngineException.cs b/src/libraries/System.Private.CoreLib/src/System/ExecutionEngineException.cs index 1cdb62dc705fe..283a70a98c9e5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ExecutionEngineException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ExecutionEngineException.cs @@ -21,13 +21,13 @@ public ExecutionEngineException() } public ExecutionEngineException(string? message) - : base(message) + : base(message ?? SR.Arg_ExecutionEngineException) { HResult = HResults.COR_E_EXECUTIONENGINE; } public ExecutionEngineException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_ExecutionEngineException, innerException) { HResult = HResults.COR_E_EXECUTIONENGINE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs index 5855b9e6c5ebc..029f65c70a534 100644 --- a/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs @@ -21,13 +21,13 @@ public FieldAccessException() } public FieldAccessException(string? message) - : base(message) + : base(message ?? SR.Arg_FieldAccessException) { HResult = HResults.COR_E_FIELDACCESS; } public FieldAccessException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_FieldAccessException, inner) { HResult = HResults.COR_E_FIELDACCESS; } diff --git a/src/libraries/System.Private.CoreLib/src/System/FormatException.cs b/src/libraries/System.Private.CoreLib/src/System/FormatException.cs index 36bb7db6db621..5fabf9dea933e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/FormatException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/FormatException.cs @@ -21,13 +21,13 @@ public FormatException() } public FormatException(string? message) - : base(message) + : base(message ?? SR.Arg_FormatException) { HResult = HResults.COR_E_FORMAT; } public FormatException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_FormatException, innerException) { HResult = HResults.COR_E_FORMAT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs index 49efb6232591e..5b9b65d3717aa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs @@ -20,40 +20,40 @@ public CultureNotFoundException() } public CultureNotFoundException(string? message) - : base(message) + : base(message ?? DefaultMessage) { } public CultureNotFoundException(string? paramName, string? message) - : base(message, paramName) + : base(message ?? DefaultMessage, paramName) { } public CultureNotFoundException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? DefaultMessage, innerException) { } public CultureNotFoundException(string? paramName, string? invalidCultureName, string? message) - : base(message, paramName) + : base(message ?? DefaultMessage, paramName) { _invalidCultureName = invalidCultureName; } public CultureNotFoundException(string? message, string? invalidCultureName, Exception? innerException) - : base(message, innerException) + : base(message ?? DefaultMessage, innerException) { _invalidCultureName = invalidCultureName; } public CultureNotFoundException(string? message, int invalidCultureId, Exception? innerException) - : base(message, innerException) + : base(message ?? DefaultMessage, innerException) { _invalidCultureId = invalidCultureId; } public CultureNotFoundException(string? paramName, int invalidCultureId, string? message) - : base(message, paramName) + : base(message ?? DefaultMessage, paramName) { _invalidCultureId = invalidCultureId; } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs index 0fe377e665456..ca651ad4c27fc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs @@ -24,13 +24,13 @@ public DirectoryNotFoundException() } public DirectoryNotFoundException(string? message) - : base(message) + : base(message ?? SR.Arg_DirectoryNotFoundException) { HResult = HResults.COR_E_DIRECTORYNOTFOUND; } public DirectoryNotFoundException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_DirectoryNotFoundException, innerException) { HResult = HResults.COR_E_DIRECTORYNOTFOUND; } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs index bc3e2e07fe254..5905204b7ae2c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs @@ -18,13 +18,13 @@ public EndOfStreamException() } public EndOfStreamException(string? message) - : base(message) + : base(message ?? SR.Arg_EndOfStreamException) { HResult = HResults.COR_E_ENDOFSTREAM; } public EndOfStreamException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_EndOfStreamException, innerException) { HResult = HResults.COR_E_ENDOFSTREAM; } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs index d928c92170aa1..dda0530108eb0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs @@ -23,7 +23,7 @@ public InvalidDataException() /// The error message that explains the reason for the exception. /// This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "An invalid argument was specified." This message is localized based on the current system culture. public InvalidDataException(string? message) - : base(message) + : base(message ?? SR.GenericInvalidData) { } @@ -33,7 +33,7 @@ public InvalidDataException(string? message) /// This constructor initializes the property of the new instance using the value of the parameter. The content of the parameter is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture. /// An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or if the property does not supply the inner exception value to the constructor. public InvalidDataException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.GenericInvalidData, innerException) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs index 280d59991556e..5e9cbf72a70a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs @@ -18,13 +18,13 @@ public PathTooLongException() } public PathTooLongException(string? message) - : base(message) + : base(message ?? SR.IO_PathTooLong) { HResult = HResults.COR_E_PATHTOOLONG; } public PathTooLongException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.IO_PathTooLong, innerException) { HResult = HResults.COR_E_PATHTOOLONG; } diff --git a/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs b/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs index d5ab3d4648a02..b80408e40779a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs @@ -20,13 +20,13 @@ public IndexOutOfRangeException() } public IndexOutOfRangeException(string? message) - : base(message) + : base(message ?? SR.Arg_IndexOutOfRangeException) { HResult = HResults.COR_E_INDEXOUTOFRANGE; } public IndexOutOfRangeException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_IndexOutOfRangeException, innerException) { HResult = HResults.COR_E_INDEXOUTOFRANGE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs b/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs index b6a8d865055ad..3a0b1a5e214f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs @@ -17,13 +17,13 @@ public InsufficientExecutionStackException() } public InsufficientExecutionStackException(string? message) - : base(message) + : base(message ?? SR.Arg_InsufficientExecutionStackException) { HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; } public InsufficientExecutionStackException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_InsufficientExecutionStackException, innerException) { HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; } diff --git a/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs b/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs index c2ba90170cf9f..30befd22fa2f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs @@ -18,29 +18,30 @@ namespace System [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class InsufficientMemoryException : OutOfMemoryException { - public InsufficientMemoryException() : base( -#if CORECLR - GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory) -#else - SR.Arg_OutOfMemoryException -#endif - ) + public InsufficientMemoryException() : base(GetDefaultMessage()) { HResult = HResults.COR_E_INSUFFICIENTMEMORY; } public InsufficientMemoryException(string? message) - : base(message) + : base(message ?? GetDefaultMessage()) { HResult = HResults.COR_E_INSUFFICIENTMEMORY; } public InsufficientMemoryException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? GetDefaultMessage(), innerException) { HResult = HResults.COR_E_INSUFFICIENTMEMORY; } + private static string GetDefaultMessage() +#if CORECLR + => GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory); +#else + => SR.Arg_OutOfMemoryException; +#endif + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs index 7e97f583a3ef1..024717bfe70df 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs @@ -21,19 +21,19 @@ public InvalidCastException() } public InvalidCastException(string? message) - : base(message) + : base(message ?? SR.Arg_InvalidCastException) { HResult = HResults.COR_E_INVALIDCAST; } public InvalidCastException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_InvalidCastException, innerException) { HResult = HResults.COR_E_INVALIDCAST; } public InvalidCastException(string? message, int errorCode) - : base(message) + : base(message ?? SR.Arg_InvalidCastException) { HResult = errorCode; } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs index 97233835319c0..394e5c78e533f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs @@ -21,13 +21,13 @@ public InvalidOperationException() } public InvalidOperationException(string? message) - : base(message) + : base(message ?? SR.Arg_InvalidOperationException) { HResult = HResults.COR_E_INVALIDOPERATION; } public InvalidOperationException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_InvalidOperationException, innerException) { HResult = HResults.COR_E_INVALIDOPERATION; } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs index c59cad49ac3a0..0cda622cb2222 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs @@ -21,13 +21,13 @@ public InvalidProgramException() } public InvalidProgramException(string? message) - : base(message) + : base(message ?? SR.InvalidProgram_Default) { HResult = HResults.COR_E_INVALIDPROGRAM; } public InvalidProgramException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.InvalidProgram_Default, inner) { HResult = HResults.COR_E_INVALIDPROGRAM; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs index 9e4cbdf085cf3..1d1839a14596f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs @@ -33,13 +33,13 @@ public MemberAccessException() // and its ExceptionInfo reference set to null. // public MemberAccessException(string? message) - : base(message) + : base(message ?? SR.Arg_AccessException) { HResult = HResults.COR_E_MEMBERACCESS; } public MemberAccessException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_AccessException, inner) { HResult = HResults.COR_E_MEMBERACCESS; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs index 1777f153f3806..910db3d80d160 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs @@ -21,13 +21,13 @@ public MethodAccessException() } public MethodAccessException(string? message) - : base(message) + : base(message ?? SR.Arg_MethodAccessException) { HResult = HResults.COR_E_METHODACCESS; } public MethodAccessException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MethodAccessException, inner) { HResult = HResults.COR_E_METHODACCESS; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs index 7d64f0f11aa47..2a216333de493 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs @@ -18,13 +18,13 @@ public MissingFieldException() } public MissingFieldException(string? message) - : base(message) + : base(message ?? SR.Arg_MissingFieldException) { HResult = HResults.COR_E_MISSINGFIELD; } public MissingFieldException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MissingFieldException, inner) { HResult = HResults.COR_E_MISSINGFIELD; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs index 4fb2cb230d64c..bc2e368efa179 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs @@ -18,13 +18,13 @@ public MissingMemberException() } public MissingMemberException(string? message) - : base(message) + : base(message ?? SR.Arg_MissingMemberException) { HResult = HResults.COR_E_MISSINGMEMBER; } public MissingMemberException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MissingMemberException, inner) { HResult = HResults.COR_E_MISSINGMEMBER; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs index 9399470cef91a..b9bf68c4f91a0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs @@ -21,13 +21,13 @@ public MissingMethodException() } public MissingMethodException(string? message) - : base(message) + : base(message ?? SR.Arg_MissingMethodException) { HResult = HResults.COR_E_MISSINGMETHOD; } public MissingMethodException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MissingMethodException, inner) { HResult = HResults.COR_E_MISSINGMETHOD; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs index 6f022c61305e7..01b2c66f2934b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs @@ -22,13 +22,13 @@ public MulticastNotSupportedException() } public MulticastNotSupportedException(string? message) - : base(message) + : base(message ?? SR.Arg_MulticastNotSupportedException) { HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; } public MulticastNotSupportedException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MulticastNotSupportedException, inner) { HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs b/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs index 88fe578c51dc0..558a29543cd13 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs @@ -27,27 +27,27 @@ public NotFiniteNumberException(double offendingNumber) } public NotFiniteNumberException(string? message) - : base(message) + : base(message ?? SR.Arg_NotFiniteNumberException) { _offendingNumber = 0; HResult = HResults.COR_E_NOTFINITENUMBER; } public NotFiniteNumberException(string? message, double offendingNumber) - : base(message) + : base(message ?? SR.Arg_NotFiniteNumberException) { _offendingNumber = offendingNumber; HResult = HResults.COR_E_NOTFINITENUMBER; } public NotFiniteNumberException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_NotFiniteNumberException, innerException) { HResult = HResults.COR_E_NOTFINITENUMBER; } public NotFiniteNumberException(string? message, double offendingNumber, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_NotFiniteNumberException, innerException) { _offendingNumber = offendingNumber; HResult = HResults.COR_E_NOTFINITENUMBER; diff --git a/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs b/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs index 17062b45a4557..383ad0e76300b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs @@ -20,12 +20,12 @@ public NotImplementedException() HResult = HResults.E_NOTIMPL; } public NotImplementedException(string? message) - : base(message) + : base(message ?? SR.Arg_NotImplementedException) { HResult = HResults.E_NOTIMPL; } public NotImplementedException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_NotImplementedException, inner) { HResult = HResults.E_NOTIMPL; } diff --git a/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs index 40e638d01b7b5..e1278c6f3fbe1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs @@ -22,13 +22,13 @@ public NotSupportedException() } public NotSupportedException(string? message) - : base(message) + : base(message ?? SR.Arg_NotSupportedException) { HResult = HResults.COR_E_NOTSUPPORTED; } public NotSupportedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_NotSupportedException, innerException) { HResult = HResults.COR_E_NOTSUPPORTED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs b/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs index 095b4310627fe..ed414e6b8527f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs @@ -21,13 +21,13 @@ public NullReferenceException() } public NullReferenceException(string? message) - : base(message) + : base(message ?? SR.Arg_NullReferenceException) { HResult = HResults.E_POINTER; } public NullReferenceException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_NullReferenceException, innerException) { HResult = HResults.E_POINTER; } diff --git a/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs b/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs index e0360d7eddca6..e7098478a6490 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs @@ -29,14 +29,14 @@ public ObjectDisposedException(string? objectName) : { } - public ObjectDisposedException(string? objectName, string? message) : base(message) + public ObjectDisposedException(string? objectName, string? message) : base(message ?? SR.ObjectDisposed_Generic) { HResult = HResults.COR_E_OBJECTDISPOSED; _objectName = objectName; } public ObjectDisposedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.ObjectDisposed_Generic, innerException) { HResult = HResults.COR_E_OBJECTDISPOSED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs b/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs index 2a01950c0df8d..884f43b779774 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs @@ -31,13 +31,13 @@ public OperationCanceledException() } public OperationCanceledException(string? message) - : base(message) + : base(message ?? SR.OperationCanceled) { HResult = HResults.COR_E_OPERATIONCANCELED; } public OperationCanceledException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.OperationCanceled, innerException) { HResult = HResults.COR_E_OPERATIONCANCELED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs b/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs index f6f6430ec0529..a9615f363730a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs @@ -14,29 +14,30 @@ namespace System [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class OutOfMemoryException : SystemException { - public OutOfMemoryException() : base( -#if CORECLR - GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory) -#else - SR.Arg_OutOfMemoryException -#endif - ) + public OutOfMemoryException() : base(GetDefaultMessage()) { HResult = HResults.COR_E_OUTOFMEMORY; } public OutOfMemoryException(string? message) - : base(message) + : base(message ?? GetDefaultMessage()) { HResult = HResults.COR_E_OUTOFMEMORY; } public OutOfMemoryException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? GetDefaultMessage(), innerException) { HResult = HResults.COR_E_OUTOFMEMORY; } + private static string GetDefaultMessage() +#if CORECLR + => GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory); +#else + => SR.Arg_OutOfMemoryException; +#endif + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] protected OutOfMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) diff --git a/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs b/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs index 04cdf39076c86..5374bd19b5c93 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs @@ -21,13 +21,13 @@ public OverflowException() } public OverflowException(string? message) - : base(message) + : base(message ?? SR.Arg_OverflowException) { HResult = HResults.COR_E_OVERFLOW; } public OverflowException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_OverflowException, innerException) { HResult = HResults.COR_E_OVERFLOW; } diff --git a/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs index 26932e64ac2c2..ef0bd733f7ee7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs @@ -21,13 +21,13 @@ public PlatformNotSupportedException() } public PlatformNotSupportedException(string? message) - : base(message) + : base(message ?? SR.Arg_PlatformNotSupported) { HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; } public PlatformNotSupportedException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_PlatformNotSupported, inner) { HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/RankException.cs b/src/libraries/System.Private.CoreLib/src/System/RankException.cs index 0db381b36d422..afd4d07833a8a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/RankException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/RankException.cs @@ -21,13 +21,13 @@ public RankException() } public RankException(string? message) - : base(message) + : base(message ?? SR.Arg_RankException) { HResult = HResults.COR_E_RANK; } public RankException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_RankException, innerException) { HResult = HResults.COR_E_RANK; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs index 6e75c436efa3a..23cfbf2dd43b8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs @@ -17,13 +17,13 @@ public AmbiguousMatchException() } public AmbiguousMatchException(string? message) - : base(message) + : base(message ?? SR.Arg_AmbiguousMatchException_NoMessage) { HResult = HResults.COR_E_AMBIGUOUSMATCH; } public AmbiguousMatchException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_AmbiguousMatchException_NoMessage, inner) { HResult = HResults.COR_E_AMBIGUOUSMATCH; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs index b70a1c471b710..8a6d02e76c062 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs @@ -22,7 +22,7 @@ public CustomAttributeFormatException(string? message) } public CustomAttributeFormatException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_CustomAttributeFormatException, inner) { HResult = HResults.COR_E_CUSTOMATTRIBUTEFORMAT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs index 5efdf3ee6f2d1..f64932d2677e6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs @@ -22,7 +22,7 @@ public InvalidFilterCriteriaException(string? message) } public InvalidFilterCriteriaException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_InvalidFilterCriteriaException, inner) { HResult = HResults.COR_E_INVALIDFILTERCRITERIA; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs index 04219ef4b90bb..5bc0e1e35c924 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs @@ -17,7 +17,7 @@ public TargetInvocationException(Exception? inner) } public TargetInvocationException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_TargetInvocationException, inner) { HResult = HResults.COR_E_TARGETINVOCATION; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs index be8841c7a7ed9..4962492b59a3d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs @@ -17,13 +17,13 @@ public TargetParameterCountException() } public TargetParameterCountException(string? message) - : base(message) + : base(message ?? SR.Arg_TargetParameterCountException) { HResult = HResults.COR_E_TARGETPARAMCOUNT; } public TargetParameterCountException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_TargetParameterCountException, inner) { HResult = HResults.COR_E_TARGETPARAMCOUNT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs index 05c204d2d04b9..3b095e92ac8e6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs @@ -19,13 +19,13 @@ public MissingManifestResourceException() } public MissingManifestResourceException(string? message) - : base(message) + : base(message ?? SR.Arg_MissingManifestResourceException) { HResult = HResults.COR_E_MISSINGMANIFESTRESOURCE; } public MissingManifestResourceException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MissingManifestResourceException, inner) { HResult = HResults.COR_E_MISSINGMANIFESTRESOURCE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs index 2e1c0bd2af84d..fb60055555ec6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs @@ -23,20 +23,20 @@ public MissingSatelliteAssemblyException() } public MissingSatelliteAssemblyException(string? message) - : base(message) + : base(message ?? SR.MissingSatelliteAssembly_Default) { HResult = HResults.COR_E_MISSINGSATELLITEASSEMBLY; } public MissingSatelliteAssemblyException(string? message, string? cultureName) - : base(message) + : base(message ?? SR.MissingSatelliteAssembly_Default) { HResult = HResults.COR_E_MISSINGSATELLITEASSEMBLY; _cultureName = cultureName; } public MissingSatelliteAssemblyException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.MissingSatelliteAssembly_Default, inner) { HResult = HResults.COR_E_MISSINGSATELLITEASSEMBLY; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs index d5a85c2eef3ac..efcc70be29917 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs @@ -17,13 +17,13 @@ public AmbiguousImplementationException() } public AmbiguousImplementationException(string? message) - : base(message) + : base(message ?? SR.Arg_AmbiguousImplementationException_NoMessage) { HResult = HResults.COR_E_AMBIGUOUSIMPLEMENTATION; } public AmbiguousImplementationException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_AmbiguousImplementationException_NoMessage, innerException) { HResult = HResults.COR_E_AMBIGUOUSIMPLEMENTATION; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs index b9a358eb538ec..b6d4206a80078 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs @@ -35,10 +35,10 @@ private SwitchExpressionException(SerializationInfo info, StreamingContext conte UnmatchedValue = info.GetValue(nameof(UnmatchedValue), typeof(object)); } - public SwitchExpressionException(string? message) : base(message) { } + public SwitchExpressionException(string? message) : base(message ?? SR.Arg_SwitchExpressionException) { } public SwitchExpressionException(string? message, Exception? innerException) - : base(message, innerException) { } + : base(message ?? SR.Arg_SwitchExpressionException, innerException) { } public object? UnmatchedValue { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs index c74821e21c685..5a1f5df90270a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs @@ -24,19 +24,19 @@ public COMException() } public COMException(string? message) - : base(message) + : base(message ?? SR.Arg_COMException) { HResult = HResults.E_FAIL; } public COMException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_COMException, inner) { HResult = HResults.E_FAIL; } public COMException(string? message, int errorCode) - : base(message) + : base(message ?? SR.Arg_COMException) { HResult = errorCode; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs index 6f148661d849e..7285e4c175fe3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs @@ -21,19 +21,19 @@ public ExternalException() } public ExternalException(string? message) - : base(message) + : base(message ?? SR.Arg_ExternalException) { HResult = HResults.E_FAIL; } public ExternalException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_ExternalException, inner) { HResult = HResults.E_FAIL; } public ExternalException(string? message, int errorCode) - : base(message) + : base(message ?? SR.Arg_ExternalException) { HResult = errorCode; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs index 4090c2f25437b..b618434c0f9de 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs @@ -23,13 +23,13 @@ public InvalidComObjectException() } public InvalidComObjectException(string? message) - : base(message) + : base(message ?? SR.Arg_InvalidComObjectException) { HResult = HResults.COR_E_INVALIDCOMOBJECT; } public InvalidComObjectException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_InvalidComObjectException, inner) { HResult = HResults.COR_E_INVALIDCOMOBJECT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs index 1f900d58a4397..705a46eecac54 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs @@ -22,13 +22,13 @@ public InvalidOleVariantTypeException() } public InvalidOleVariantTypeException(string? message) - : base(message) + : base(message ?? SR.Arg_InvalidOleVariantTypeException) { HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; } public InvalidOleVariantTypeException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_InvalidOleVariantTypeException, inner) { HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs index d6f2a78cdfa74..98bcd9ba28526 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs @@ -21,13 +21,13 @@ public MarshalDirectiveException() } public MarshalDirectiveException(string? message) - : base(message) + : base(message ?? SR.Arg_MarshalDirectiveException) { HResult = HResults.COR_E_MARSHALDIRECTIVE; } public MarshalDirectiveException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_MarshalDirectiveException, inner) { HResult = HResults.COR_E_MARSHALDIRECTIVE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs index 37e1a657931c1..80646bb513ba9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs @@ -22,13 +22,13 @@ public SafeArrayRankMismatchException() } public SafeArrayRankMismatchException(string? message) - : base(message) + : base(message ?? SR.Arg_SafeArrayRankMismatchException) { HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; } public SafeArrayRankMismatchException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_SafeArrayRankMismatchException, inner) { HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs index 4211cc93e6aed..8434bd4781296 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs @@ -22,13 +22,13 @@ public SafeArrayTypeMismatchException() } public SafeArrayTypeMismatchException(string? message) - : base(message) + : base(message ?? SR.Arg_SafeArrayTypeMismatchException) { HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; } public SafeArrayTypeMismatchException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_SafeArrayTypeMismatchException, inner) { HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs index 4831d57cd469e..a25de2ea80e51 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs @@ -21,13 +21,13 @@ public SerializationException() } public SerializationException(string? message) - : base(message) + : base(message ?? SR.SerializationException) { HResult = HResults.COR_E_SERIALIZATION; } public SerializationException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.SerializationException, innerException) { HResult = HResults.COR_E_SERIALIZATION; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs index 6c8eab8a896f4..14bf748bcc810 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs @@ -24,12 +24,12 @@ public CryptographicException(int hr) } public CryptographicException(string? message) - : base(message) + : base(message ?? SR.Arg_CryptographyException) { } public CryptographicException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_CryptographyException, inner) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs index 786348af0329a..f82d44c186b88 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs @@ -26,26 +26,26 @@ public SecurityException() } public SecurityException(string? message) - : base(message) + : base(message ?? SR.Arg_SecurityException) { HResult = HResults.COR_E_SECURITY; } public SecurityException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_SecurityException, inner) { HResult = HResults.COR_E_SECURITY; } public SecurityException(string? message, Type? type) - : base(message) + : base(message ?? SR.Arg_SecurityException) { HResult = HResults.COR_E_SECURITY; PermissionType = type; } public SecurityException(string? message, Type? type, string? state) - : base(message) + : base(message ?? SR.Arg_SecurityException) { HResult = HResults.COR_E_SECURITY; PermissionType = type; diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs index d91ce07a341e3..b82a607ec4bec 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs @@ -18,13 +18,13 @@ public VerificationException() } public VerificationException(string? message) - : base(message) + : base(message ?? SR.Verification_Exception) { HResult = HResults.COR_E_VERIFICATION; } public VerificationException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Verification_Exception, innerException) { HResult = HResults.COR_E_VERIFICATION; } diff --git a/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs b/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs index 9d0b2ed65b56c..c43e4a1a5e9c8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs @@ -20,13 +20,13 @@ public StackOverflowException() } public StackOverflowException(string? message) - : base(message) + : base(message ?? SR.Arg_StackOverflowException) { HResult = HResults.COR_E_STACKOVERFLOW; } public StackOverflowException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_StackOverflowException, innerException) { HResult = HResults.COR_E_STACKOVERFLOW; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs index f7cfe86f3b646..ca0b897bcdf72 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs @@ -21,13 +21,13 @@ public AbandonedMutexException() } public AbandonedMutexException(string? message) - : base(message) + : base(message ?? SR.Threading_AbandonedMutexException) { HResult = HResults.COR_E_ABANDONEDMUTEX; } public AbandonedMutexException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Threading_AbandonedMutexException, inner) { HResult = HResults.COR_E_ABANDONEDMUTEX; } @@ -40,14 +40,14 @@ public AbandonedMutexException(int location, WaitHandle? handle) } public AbandonedMutexException(string? message, int location, WaitHandle? handle) - : base(message) + : base(message ?? SR.Threading_AbandonedMutexException) { HResult = HResults.COR_E_ABANDONEDMUTEX; SetupException(location, handle); } public AbandonedMutexException(string? message, Exception? inner, int location, WaitHandle? handle) - : base(message, inner) + : base(message ?? SR.Threading_AbandonedMutexException, inner) { HResult = HResults.COR_E_ABANDONEDMUTEX; SetupException(location, handle); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs index 339e637580af8..221c70f8b1901 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs @@ -15,11 +15,11 @@ public SemaphoreFullException() : base(SR.Threading_SemaphoreFullException) { } - public SemaphoreFullException(string? message) : base(message) + public SemaphoreFullException(string? message) : base(message ?? SR.Threading_SemaphoreFullException) { } - public SemaphoreFullException(string? message, Exception? innerException) : base(message, innerException) + public SemaphoreFullException(string? message, Exception? innerException) : base(message ?? SR.Threading_SemaphoreFullException, innerException) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs index 158a3fdb3ab7d..0aa4eee04f038 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs @@ -21,13 +21,13 @@ public SynchronizationLockException() } public SynchronizationLockException(string? message) - : base(message) + : base(message ?? SR.Arg_SynchronizationLockException) { HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; } public SynchronizationLockException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_SynchronizationLockException, innerException) { HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs index 16c2c779da4ea..bade3751d7aa9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs @@ -37,7 +37,7 @@ public TaskCanceledException() : base(SR.TaskCanceledException_ctor_DefaultMessa /// class with a specified error message. /// /// The error message that explains the reason for the exception. - public TaskCanceledException(string? message) : base(message) + public TaskCanceledException(string? message) : base(message ?? SR.TaskCanceledException_ctor_DefaultMessage) { } @@ -48,7 +48,7 @@ public TaskCanceledException(string? message) : base(message) /// /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception. - public TaskCanceledException(string? message, Exception? innerException) : base(message, innerException) + public TaskCanceledException(string? message, Exception? innerException) : base(message ?? SR.TaskCanceledException_ctor_DefaultMessage, innerException) { } @@ -60,7 +60,7 @@ public TaskCanceledException(string? message, Exception? innerException) : base( /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception. /// The that triggered the cancellation. - public TaskCanceledException(string? message, Exception? innerException, CancellationToken token) : base(message, innerException, token) + public TaskCanceledException(string? message, Exception? innerException, CancellationToken token) : base(message ?? SR.TaskCanceledException_ctor_DefaultMessage, innerException, token) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs index d935bbcc69646..8615855f15dd9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs @@ -35,7 +35,7 @@ public TaskSchedulerException() : base(SR.TaskSchedulerException_ctor_DefaultMes /// class with a specified error message. /// /// The error message that explains the reason for the exception. - public TaskSchedulerException(string? message) : base(message) + public TaskSchedulerException(string? message) : base(message ?? SR.TaskSchedulerException_ctor_DefaultMessage) { } @@ -57,7 +57,7 @@ public TaskSchedulerException(Exception? innerException) /// /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception. - public TaskSchedulerException(string? message, Exception? innerException) : base(message, innerException) + public TaskSchedulerException(string? message, Exception? innerException) : base(message ?? SR.TaskSchedulerException_ctor_DefaultMessage, innerException) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs index 193747c944c34..927f1fa6d84f0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs @@ -14,29 +14,30 @@ namespace System.Threading [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ThreadInterruptedException : SystemException { - public ThreadInterruptedException() : base( -#if CORECLR - GetMessageFromNativeResources(ExceptionMessageKind.ThreadInterrupted) -#else - SR.Threading_ThreadInterrupted -#endif - ) + public ThreadInterruptedException() : base(GetDefaultMessage()) { HResult = HResults.COR_E_THREADINTERRUPTED; } public ThreadInterruptedException(string? message) - : base(message) + : base(message ?? GetDefaultMessage()) { HResult = HResults.COR_E_THREADINTERRUPTED; } public ThreadInterruptedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? GetDefaultMessage(), innerException) { HResult = HResults.COR_E_THREADINTERRUPTED; } + private static string GetDefaultMessage() +#if CORECLR + => GetMessageFromNativeResources(ExceptionMessageKind.ThreadInterrupted); +#else + => SR.Threading_ThreadInterrupted; +#endif + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] protected ThreadInterruptedException(SerializationInfo info, StreamingContext context) : base(info, context) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs index 81118f6dee0ed..6a3cd0d0b6d38 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs @@ -21,13 +21,13 @@ public ThreadStateException() } public ThreadStateException(string? message) - : base(message) + : base(message ?? SR.Arg_ThreadStateException) { HResult = HResults.COR_E_THREADSTATE; } public ThreadStateException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_ThreadStateException, innerException) { HResult = HResults.COR_E_THREADSTATE; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs index 2babfd6e21346..bd4d74cb513c0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs @@ -16,12 +16,12 @@ public WaitHandleCannotBeOpenedException() : base(SR.Threading_WaitHandleCannotB HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } - public WaitHandleCannotBeOpenedException(string? message) : base(message) + public WaitHandleCannotBeOpenedException(string? message) : base(message ?? SR.Threading_WaitHandleCannotBeOpenedException) { HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } - public WaitHandleCannotBeOpenedException(string? message, Exception? innerException) : base(message, innerException) + public WaitHandleCannotBeOpenedException(string? message, Exception? innerException) : base(message ?? SR.Threading_WaitHandleCannotBeOpenedException, innerException) { HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs b/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs index 29f6155094e03..ffe14b6898db4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs @@ -21,13 +21,13 @@ public TimeoutException() } public TimeoutException(string? message) - : base(message) + : base(message ?? SR.Arg_TimeoutException) { HResult = HResults.COR_E_TIMEOUT; } public TimeoutException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_TimeoutException, innerException) { HResult = HResults.COR_E_TIMEOUT; } diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs index 4068ac3b81602..418efbe9e2844 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs @@ -20,13 +20,13 @@ public TypeAccessException() } public TypeAccessException(string? message) - : base(message) + : base(message ?? SR.Arg_TypeAccessException) { HResult = HResults.COR_E_TYPEACCESS; } public TypeAccessException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_TypeAccessException, inner) { HResult = HResults.COR_E_TYPEACCESS; } diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs index 99994113a0d55..912dd77a46f73 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs @@ -32,13 +32,13 @@ public TypeInitializationException(string? fullTypeName, Exception? innerExcepti // This is called from within the runtime. I believe this is necessary // for Interop only, though it's not particularly useful. - internal TypeInitializationException(string? message) : base(message) + internal TypeInitializationException(string? message) : base(message ?? SR.TypeInitialization_Default) { HResult = HResults.COR_E_TYPEINITIALIZATION; } internal TypeInitializationException(string? fullTypeName, string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.TypeInitialization_Default, innerException) { _typeName = fullTypeName; HResult = HResults.COR_E_TYPEINITIALIZATION; diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs index aff385f678bfd..d4fcc651db375 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs @@ -18,13 +18,13 @@ public TypeUnloadedException() } public TypeUnloadedException(string? message) - : base(message) + : base(message ?? SR.Arg_TypeUnloadedException) { HResult = HResults.COR_E_TYPEUNLOADED; } public TypeUnloadedException(string? message, Exception? innerException) - : base(message, innerException) + : base(message ?? SR.Arg_TypeUnloadedException, innerException) { HResult = HResults.COR_E_TYPEUNLOADED; } diff --git a/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs index 88d89e1fee271..053d6fc39df91 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs @@ -21,13 +21,13 @@ public UnauthorizedAccessException() } public UnauthorizedAccessException(string? message) - : base(message) + : base(message ?? SR.Arg_UnauthorizedAccessException) { HResult = HResults.COR_E_UNAUTHORIZEDACCESS; } public UnauthorizedAccessException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_UnauthorizedAccessException, inner) { HResult = HResults.COR_E_UNAUTHORIZEDACCESS; } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AuthenticationTagMismatchException.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AuthenticationTagMismatchException.cs index 6c63045da0f13..e09b0ec149764 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AuthenticationTagMismatchException.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AuthenticationTagMismatchException.cs @@ -24,7 +24,7 @@ public AuthenticationTagMismatchException() : base(SR.Cryptography_AuthTagMismat /// /// The error message that explains the reason for the exception. /// - public AuthenticationTagMismatchException(string? message) : base(message) + public AuthenticationTagMismatchException(string? message) : base(message ?? SR.Cryptography_AuthTagMismatch) { } @@ -40,7 +40,7 @@ public AuthenticationTagMismatchException(string? message) : base(message) /// , the current exception is raised in a catch block that handles the inner exception. /// public AuthenticationTagMismatchException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Cryptography_AuthTagMismatch, inner) { } } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs index 508b39fbcf603..a5825728278ce 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs @@ -17,12 +17,12 @@ public CryptographicUnexpectedOperationException() } public CryptographicUnexpectedOperationException(string? message) - : base(message) + : base(message ?? SR.Arg_CryptographyException) { } public CryptographicUnexpectedOperationException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.Arg_CryptographyException, inner) { } diff --git a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs index 157ac1ffe20ef..4a97e251123fe 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs +++ b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs @@ -18,12 +18,12 @@ public IdentityNotMappedException() } public IdentityNotMappedException(string? message) - : base(message) + : base(message ?? SR.IdentityReference_IdentityNotMapped) { } public IdentityNotMappedException(string? message, Exception? inner) - : base(message, inner) + : base(message ?? SR.IdentityReference_IdentityNotMapped, inner) { } diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs index aac7f3420da9a..198bd6340a95a 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs @@ -32,7 +32,7 @@ public RegexMatchTimeoutException(string regexInput, string regexPattern, TimeSp /// developers should prefer using the constructor /// public RegexMatchTimeoutException(string input, string pattern, TimeSpan matchTimeout). /// - public RegexMatchTimeoutException() { } + public RegexMatchTimeoutException() : base(SR.RegexMatchTimeoutException_Occurred) { } /// /// This constructor is provided in compliance with common .NET Framework design patterns; @@ -40,7 +40,7 @@ public RegexMatchTimeoutException() { } /// public RegexMatchTimeoutException(string input, string pattern, TimeSpan matchTimeout). /// /// The error message that explains the reason for the exception. - public RegexMatchTimeoutException(string message) : base(message) { } + public RegexMatchTimeoutException(string message) : base(message ?? SR.RegexMatchTimeoutException_Occurred) { } /// /// This constructor is provided in compliance with common .NET Framework design patterns; @@ -49,7 +49,7 @@ public RegexMatchTimeoutException(string message) : base(message) { } /// /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception, or a null. - public RegexMatchTimeoutException(string message, Exception inner) : base(message, inner) { } + public RegexMatchTimeoutException(string message, Exception inner) : base(message ?? SR.RegexMatchTimeoutException_Occurred, inner) { } [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.cs index b3c4151e13370..1a79350e5fd7e 100644 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.cs +++ b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.cs @@ -12,7 +12,7 @@ public ChannelClosedException() : /// Initializes a new instance of the class. /// The message that describes the error. - public ChannelClosedException(string? message) : base(message) { } + public ChannelClosedException(string? message) : base(message ?? SR.ChannelClosedException_DefaultMessage) { } /// Initializes a new instance of the class. /// The exception that is the cause of this exception. @@ -22,6 +22,6 @@ public ChannelClosedException(Exception? innerException) : /// Initializes a new instance of the class. /// The message that describes the error. /// The exception that is the cause of this exception. - public ChannelClosedException(string? message, Exception? innerException) : base(message, innerException) { } + public ChannelClosedException(string? message, Exception? innerException) : base(message ?? SR.ChannelClosedException_DefaultMessage, innerException) { } } } diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs index cb850655b69b0..eee3545ae7ebe 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs @@ -181,7 +181,7 @@ public TransactionAbortedException() : base(SR.TransactionAborted) /// /// /// - public TransactionAbortedException(string? message) : base(message) + public TransactionAbortedException(string? message) : base(message ?? SR.TransactionAborted) { } @@ -190,7 +190,7 @@ public TransactionAbortedException(string? message) : base(message) /// /// /// - public TransactionAbortedException(string? message, Exception? innerException) : base(message, innerException) + public TransactionAbortedException(string? message, Exception? innerException) : base(message ?? SR.TransactionAborted, innerException) { } @@ -259,7 +259,7 @@ public TransactionInDoubtException() : base(SR.TransactionIndoubt) /// /// /// - public TransactionInDoubtException(string? message) : base(message) + public TransactionInDoubtException(string? message) : base(message ?? SR.TransactionIndoubt) { } @@ -268,7 +268,7 @@ public TransactionInDoubtException(string? message) : base(message) /// /// /// - public TransactionInDoubtException(string? message, Exception? innerException) : base(message, innerException) + public TransactionInDoubtException(string? message, Exception? innerException) : base(message ?? SR.TransactionIndoubt, innerException) { } @@ -318,7 +318,7 @@ public TransactionManagerCommunicationException() : base(SR.TransactionManagerCo /// /// /// - public TransactionManagerCommunicationException(string? message) : base(message) + public TransactionManagerCommunicationException(string? message) : base(message ?? SR.TransactionManagerCommunicationException) { } @@ -330,7 +330,7 @@ public TransactionManagerCommunicationException(string? message) : base(message) public TransactionManagerCommunicationException( string? message, Exception? innerException - ) : base(message, innerException) + ) : base(message ?? SR.TransactionManagerCommunicationException, innerException) { } @@ -361,7 +361,7 @@ public TransactionPromotionException() : this(SR.PromotionFailed) /// /// /// - public TransactionPromotionException(string? message) : base(message) + public TransactionPromotionException(string? message) : base(message ?? SR.PromotionFailed) { } @@ -370,7 +370,7 @@ public TransactionPromotionException(string? message) : base(message) /// /// /// - public TransactionPromotionException(string? message, Exception? innerException) : base(message, innerException) + public TransactionPromotionException(string? message, Exception? innerException) : base(message ?? SR.PromotionFailed, innerException) { }