Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Nullable: All remaining exceptions #23676

Merged
merged 2 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

#nullable enable
namespace Internal.Resources
{
public class PRIExceptionInfo
{
public string PackageSimpleName;
public string ResWFile;
public string? PackageSimpleName;
public string? ResWFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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.

using System;
#nullable enable
using System.Runtime.Serialization;

namespace System.Collections.Generic
Expand All @@ -17,13 +17,13 @@ public KeyNotFoundException()
HResult = HResults.COR_E_KEYNOTFOUND;
}

public KeyNotFoundException(string message)
public KeyNotFoundException(string? message)
: base(message)
{
HResult = HResults.COR_E_KEYNOTFOUND;
}

public KeyNotFoundException(string message, Exception innerException)
public KeyNotFoundException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_KEYNOTFOUND;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +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.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
#nullable enable
using System.Runtime.Serialization;

namespace System.Diagnostics.Contracts
Expand All @@ -17,21 +13,21 @@ namespace System.Diagnostics.Contracts
public sealed class ContractException : Exception
{
private readonly ContractFailureKind _kind;
private readonly string _userMessage;
private readonly string _condition;
private readonly string? _userMessage;
private readonly string? _condition;

public ContractFailureKind Kind { get { return _kind; } }
public string Failure { get { return this.Message; } }
public string UserMessage { get { return _userMessage; } }
public string Condition { get { return _condition; } }
public ContractFailureKind Kind => _kind;
public string Failure => this.Message;
public string? UserMessage => _userMessage;
public string? Condition => _condition;

// Called by COM Interop, if we see COR_E_CODECONTRACTFAILED as an HRESULT.
private ContractException()
{
HResult = HResults.COR_E_CODECONTRACTFAILED;
}

public ContractException(ContractFailureKind kind, string failure, string userMessage, string condition, Exception innerException)
public ContractException(ContractFailureKind kind, string? failure, string? userMessage, string? condition, Exception? innerException)
: base(failure, innerException)
{
HResult = HResults.COR_E_CODECONTRACTFAILED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +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.

using System;
using System.Resources;
#nullable enable
using System.Runtime.Serialization;

#if ES_BUILD_STANDALONE
Expand Down Expand Up @@ -33,13 +32,13 @@ public EventSourceException() :
/// <summary>
/// Initializes a new instance of the EventSourceException class with a specified error message.
/// </summary>
public EventSourceException(string message) : base(message) { }
public EventSourceException(string? message) : base(message) { }

/// <summary>
/// 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.
/// </summary>
public EventSourceException(string message, Exception innerException) : base(message, innerException) { }
public EventSourceException(string? message, Exception? innerException) : base(message, innerException) { }

#if !ES_BUILD_PCL
/// <summary>
Expand All @@ -48,7 +47,7 @@ public EventSourceException(string message, Exception innerException) : base(mes
protected EventSourceException(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endif

internal EventSourceException(Exception innerException) :
internal EventSourceException(Exception? innerException) :
base(SR.EventSource_ListenerWriteFailure, innerException) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.IO
Expand All @@ -22,13 +23,13 @@ public DirectoryNotFoundException()
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
}

public DirectoryNotFoundException(string message)
public DirectoryNotFoundException(string? message)
: base(message)
{
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
}

public DirectoryNotFoundException(string message, Exception innerException)
public DirectoryNotFoundException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.IO
Expand All @@ -16,13 +17,13 @@ public EndOfStreamException()
HResult = HResults.COR_E_ENDOFSTREAM;
}

public EndOfStreamException(string message)
public EndOfStreamException(string? message)
: base(message)
{
HResult = HResults.COR_E_ENDOFSTREAM;
}

public EndOfStreamException(string message, Exception innerException)
public EndOfStreamException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_ENDOFSTREAM;
Expand Down
13 changes: 7 additions & 6 deletions src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.IO
Expand All @@ -16,25 +17,25 @@ public FileLoadException()
HResult = HResults.COR_E_FILELOAD;
}

public FileLoadException(string message)
public FileLoadException(string? message)
: base(message)
{
HResult = HResults.COR_E_FILELOAD;
}

public FileLoadException(string message, Exception inner)
public FileLoadException(string? message, Exception? inner)
: base(message, inner)
{
HResult = HResults.COR_E_FILELOAD;
}

public FileLoadException(string message, string fileName) : base(message)
public FileLoadException(string? message, string? fileName) : base(message)
{
HResult = HResults.COR_E_FILELOAD;
FileName = fileName;
}

public FileLoadException(string message, string fileName, Exception inner)
public FileLoadException(string? message, string? fileName, Exception? inner)
: base(message, inner)
{
HResult = HResults.COR_E_FILELOAD;
Expand All @@ -53,8 +54,8 @@ public override string Message
}
}

public string FileName { get; }
public string FusionLog { get; }
public string? FileName { get; }
public string? FusionLog { get; }

public override string ToString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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.Diagnostics;
using System.Runtime.Serialization;

namespace System.IO
Expand All @@ -17,26 +19,26 @@ public FileNotFoundException()
HResult = HResults.COR_E_FILENOTFOUND;
}

public FileNotFoundException(string message)
public FileNotFoundException(string? message)
: base(message)
{
HResult = HResults.COR_E_FILENOTFOUND;
}

public FileNotFoundException(string message, Exception innerException)
public FileNotFoundException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_FILENOTFOUND;
}

public FileNotFoundException(string message, string fileName)
public FileNotFoundException(string? message, string? fileName)
: base(message)
{
HResult = HResults.COR_E_FILENOTFOUND;
FileName = fileName;
}

public FileNotFoundException(string message, string fileName, Exception innerException)
public FileNotFoundException(string? message, string? fileName, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_FILENOTFOUND;
Expand All @@ -48,6 +50,7 @@ public override string Message
get
{
SetMessageField();
Debug.Assert(_message != null, "_message was null after calling SetMessageField");
safern marked this conversation as resolved.
Show resolved Hide resolved
return _message;
}
}
Expand All @@ -65,8 +68,8 @@ private void SetMessageField()
}
}

public string FileName { get; }
public string FusionLog { get; }
public string? FileName { get; }
public string? FusionLog { get; }

public override string ToString()
{
Expand Down
8 changes: 4 additions & 4 deletions src/System.Private.CoreLib/shared/System/IO/IOException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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.

using System;
#nullable enable
using System.Runtime.Serialization;

namespace System.IO
Expand All @@ -17,19 +17,19 @@ public IOException()
HResult = HResults.COR_E_IO;
}

public IOException(string message)
public IOException(string? message)
: base(message)
{
HResult = HResults.COR_E_IO;
}

public IOException(string message, int hresult)
public IOException(string? message, int hresult)
: base(message)
{
HResult = hresult;
}

public IOException(string message, Exception innerException)
public IOException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +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.


using System;
#nullable enable
using System.Runtime.Serialization;

namespace System.IO
Expand All @@ -18,13 +17,13 @@ public PathTooLongException()
HResult = HResults.COR_E_PATHTOOLONG;
}

public PathTooLongException(string message)
public PathTooLongException(string? message)
: base(message)
{
HResult = HResults.COR_E_PATHTOOLONG;
}

public PathTooLongException(string message, Exception innerException)
public PathTooLongException(string? message, Exception? innerException)
: base(message, innerException)
{
HResult = HResults.COR_E_PATHTOOLONG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Reflection
Expand All @@ -16,13 +17,13 @@ public AmbiguousMatchException()
HResult = HResults.COR_E_AMBIGUOUSMATCH;
}

public AmbiguousMatchException(string message)
public AmbiguousMatchException(string? message)
: base(message)
{
HResult = HResults.COR_E_AMBIGUOUSMATCH;
}

public AmbiguousMatchException(string message, Exception inner)
public AmbiguousMatchException(string? message, Exception? inner)
: base(message, inner)
{
HResult = HResults.COR_E_AMBIGUOUSMATCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Reflection
Expand All @@ -15,12 +16,12 @@ public CustomAttributeFormatException()
{
}

public CustomAttributeFormatException(string message)
public CustomAttributeFormatException(string? message)
: this(message, null)
{
}

public CustomAttributeFormatException(string message, Exception inner)
public CustomAttributeFormatException(string? message, Exception? inner)
: base(message, inner)
{
HResult = HResults.COR_E_CUSTOMATTRIBUTEFORMAT;
Expand Down
Loading