summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System
diff options
context:
space:
mode:
authorSantiago Fernandez Madero <safern@microsoft.com>2019-03-28 14:59:23 -0700
committerGitHub <noreply@github.com>2019-03-28 14:59:23 -0700
commitaba605f9a7e19467c01c486cb99a3184b5528654 (patch)
tree2efd0b0b2dfe152aa8b206debae35a7b317af43b /src/System.Private.CoreLib/shared/System
parent1cdbdb09cb4938240f2358974324e77d96ff23d0 (diff)
downloadcoreclr-aba605f9a7e19467c01c486cb99a3184b5528654.tar.gz
coreclr-aba605f9a7e19467c01c486cb99a3184b5528654.tar.bz2
coreclr-aba605f9a7e19467c01c486cb99a3184b5528654.zip
Nullable: Exception, SystemException, Argument*Exception (#23515)
* Nullable: Exception, SystemException, Argument*Exception * Add Debug.Assert rather than comment
Diffstat (limited to 'src/System.Private.CoreLib/shared/System')
-rw-r--r--src/System.Private.CoreLib/shared/System/ArgumentException.cs13
-rw-r--r--src/System.Private.CoreLib/shared/System/ArgumentNullException.cs7
-rw-r--r--src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs13
-rw-r--r--src/System.Private.CoreLib/shared/System/Exception.cs17
-rw-r--r--src/System.Private.CoreLib/shared/System/SystemException.cs5
5 files changed, 30 insertions, 25 deletions
diff --git a/src/System.Private.CoreLib/shared/System/ArgumentException.cs b/src/System.Private.CoreLib/shared/System/ArgumentException.cs
index 5a918063e7..be7ffbe7fa 100644
--- a/src/System.Private.CoreLib/shared/System/ArgumentException.cs
+++ b/src/System.Private.CoreLib/shared/System/ArgumentException.cs
@@ -11,6 +11,7 @@
**
=============================================================================*/
+#nullable enable
using System.Globalization;
using System.Runtime.Serialization;
@@ -23,7 +24,7 @@ namespace System
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class ArgumentException : SystemException
{
- private string _paramName;
+ private string? _paramName;
// Creates a new ArgumentException with its message
// string set to the empty string.
@@ -36,26 +37,26 @@ namespace System
// Creates a new ArgumentException with its message
// string set to message.
//
- public ArgumentException(string message)
+ public ArgumentException(string? message)
: base(message)
{
HResult = HResults.COR_E_ARGUMENT;
}
- public ArgumentException(string message, Exception innerException)
+ public ArgumentException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_ARGUMENT;
}
- public ArgumentException(string message, string paramName, Exception innerException)
+ public ArgumentException(string? message, string? paramName, Exception? innerException)
: base(message, innerException)
{
_paramName = paramName;
HResult = HResults.COR_E_ARGUMENT;
}
- public ArgumentException(string message, string paramName)
+ public ArgumentException(string? message, string? paramName)
: base(message)
{
_paramName = paramName;
@@ -89,7 +90,7 @@ namespace System
}
}
- public virtual string ParamName
+ public virtual string? ParamName
{
get { return _paramName; }
}
diff --git a/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs b/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs
index edc38f2a4c..206c1a055b 100644
--- a/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs
+++ b/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs
@@ -11,6 +11,7 @@
**
=============================================================================*/
+#nullable enable
using System.Runtime.Serialization;
namespace System
@@ -30,19 +31,19 @@ namespace System
HResult = HResults.E_POINTER;
}
- public ArgumentNullException(string paramName)
+ public ArgumentNullException(string? paramName)
: base(SR.ArgumentNull_Generic, paramName)
{
HResult = HResults.E_POINTER;
}
- public ArgumentNullException(string message, Exception innerException)
+ public ArgumentNullException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.E_POINTER;
}
- public ArgumentNullException(string paramName, string message)
+ public ArgumentNullException(string? paramName, string? message)
: base(message, paramName)
{
HResult = HResults.E_POINTER;
diff --git a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs
index 2c1941b62b..7ca9085c63 100644
--- a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs
+++ b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs
@@ -11,6 +11,7 @@
**
=============================================================================*/
+#nullable enable
using System.Globalization;
using System.Runtime.Serialization;
@@ -22,7 +23,7 @@ namespace System
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class ArgumentOutOfRangeException : ArgumentException
{
- private object _actualValue;
+ private object? _actualValue;
// Creates a new ArgumentOutOfRangeException with its message
// string set to a default message explaining an argument was out of range.
@@ -32,19 +33,19 @@ namespace System
HResult = HResults.COR_E_ARGUMENTOUTOFRANGE;
}
- public ArgumentOutOfRangeException(string paramName)
+ public ArgumentOutOfRangeException(string? paramName)
: base(SR.Arg_ArgumentOutOfRangeException, paramName)
{
HResult = HResults.COR_E_ARGUMENTOUTOFRANGE;
}
- public ArgumentOutOfRangeException(string paramName, string message)
+ public ArgumentOutOfRangeException(string? paramName, string? message)
: base(message, paramName)
{
HResult = HResults.COR_E_ARGUMENTOUTOFRANGE;
}
- public ArgumentOutOfRangeException(string message, Exception innerException)
+ public ArgumentOutOfRangeException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_ARGUMENTOUTOFRANGE;
@@ -53,7 +54,7 @@ namespace System
// We will not use this in the classlibs, but we'll provide it for
// anyone that's really interested so they don't have to stick a bunch
// of printf's in their code.
- public ArgumentOutOfRangeException(string paramName, object actualValue, string message)
+ public ArgumentOutOfRangeException(string? paramName, object? actualValue, string? message)
: base(message, paramName)
{
_actualValue = actualValue;
@@ -92,7 +93,7 @@ namespace System
// Note - we don't set this anywhere in the class libraries in
// version 1, but it might come in handy for other developers who
// want to avoid sticking printf's in their code.
- public virtual object ActualValue
+ public virtual object? ActualValue
{
get { return _actualValue; }
}
diff --git a/src/System.Private.CoreLib/shared/System/Exception.cs b/src/System.Private.CoreLib/shared/System/Exception.cs
index 764f36a2fc..c2522d558b 100644
--- a/src/System.Private.CoreLib/shared/System/Exception.cs
+++ b/src/System.Private.CoreLib/shared/System/Exception.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Collections;
using System.Runtime.Serialization;
@@ -16,7 +17,7 @@ namespace System
_HResult = HResults.COR_E_EXCEPTION;
}
- public Exception(string message)
+ public Exception(string? message)
: this()
{
_message = message;
@@ -27,7 +28,7 @@ namespace System
// Note: the stack trace is not started until the exception
// is thrown
//
- public Exception(string message, Exception innerException)
+ public Exception(string? message, Exception? innerException)
: this()
{
_message = message;
@@ -72,7 +73,7 @@ namespace System
// This will traverse exceptions using the innerException property.
public virtual Exception GetBaseException()
{
- Exception inner = InnerException;
+ Exception? inner = InnerException;
Exception back = this;
while (inner != null)
@@ -84,12 +85,12 @@ namespace System
return back;
}
- public Exception InnerException => _innerException;
+ public Exception? InnerException => _innerException;
// Sets the help link for this exception.
// This should be in a URL/URN form, such as:
// "file:///C:/Applications/Bazzal/help.html#ErrorNum42"
- public virtual string HelpLink
+ public virtual string? HelpLink
{
get
{
@@ -101,7 +102,7 @@ namespace System
}
}
- public virtual string Source
+ public virtual string? Source
{
get
{
@@ -148,7 +149,7 @@ namespace System
{
string s = GetClassName();
- string message = (needMessage ? Message : null);
+ string? message = (needMessage ? Message : null);
if (!string.IsNullOrEmpty(message))
{
s += ": " + message;
@@ -160,7 +161,7 @@ namespace System
" " + SR.Exception_EndOfInnerExceptionStack;
}
- string stackTrace = GetStackTrace(needFileLineInfo);
+ string? stackTrace = GetStackTrace(needFileLineInfo);
if (stackTrace != null)
{
s += Environment.NewLine + stackTrace;
diff --git a/src/System.Private.CoreLib/shared/System/SystemException.cs b/src/System.Private.CoreLib/shared/System/SystemException.cs
index 9a1daf2104..8d8484de16 100644
--- a/src/System.Private.CoreLib/shared/System/SystemException.cs
+++ b/src/System.Private.CoreLib/shared/System/SystemException.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Runtime.Serialization;
namespace System
@@ -16,13 +17,13 @@ namespace System
HResult = HResults.COR_E_SYSTEM;
}
- public SystemException(string message)
+ public SystemException(string? message)
: base(message)
{
HResult = HResults.COR_E_SYSTEM;
}
- public SystemException(string message, Exception innerException)
+ public SystemException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_SYSTEM;