Skip to content

Commit 5ce35bf

Browse files
authored
Nullable: System.IO (dotnet#23732)
* Nullable: System.IO Everything exception StreamReader, StreamWriter, BinaryReader, BinaryWriter, which are waiting for some changes in master to propagate over to the feature branch. * Address PR feedback
1 parent cc99fab commit 5ce35bf

24 files changed

+132
-116
lines changed

src/System.Private.CoreLib/shared/System/IO/DisableMediaInsertionPrompt.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
#if MS_IO_REDIST
67
using System;
78

src/System.Private.CoreLib/shared/System/IO/DriveInfoInternal.Unix.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System.Diagnostics;
67
using System.Text;
78

src/System.Private.CoreLib/shared/System/IO/DriveInfoInternal.Windows.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System.Diagnostics;
67
using System.Text;
78

@@ -51,7 +52,7 @@ public static string NormalizeDriveName(string driveName)
5152
{
5253
Debug.Assert(driveName != null);
5354

54-
string name;
55+
string? name;
5556

5657
if (driveName.Length == 1)
5758
{

src/System.Private.CoreLib/shared/System/IO/EncodingCache.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System.Text;
67

78
namespace System.IO

src/System.Private.CoreLib/shared/System/IO/Error.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
6-
using System.Runtime.InteropServices;
7-
using System.Text;
8-
using System.Globalization;
9-
5+
#nullable enable
106
namespace System.IO
117
{
128
/// <summary>

src/System.Private.CoreLib/shared/System/IO/FileAccess.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System;
67

78
namespace System.IO

src/System.Private.CoreLib/shared/System/IO/FileMode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
namespace System.IO
67
{
78
// Contains constants for specifying how the OS should open a file.

src/System.Private.CoreLib/shared/System/IO/FileOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System;
67
using System.Runtime.InteropServices;
78

src/System.Private.CoreLib/shared/System/IO/FileShare.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System;
67

78
namespace System.IO

src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
56
using System.Diagnostics;
67
using System.Runtime.InteropServices;
78
using System.Text;
@@ -77,7 +78,7 @@ public static string GetTempPath()
7778
// Get the temp path from the TMPDIR environment variable.
7879
// If it's not set, just return the default path.
7980
// If it is, return it, ensuring it ends with a slash.
80-
string path = Environment.GetEnvironmentVariable(TempEnvVar);
81+
string? path = Environment.GetEnvironmentVariable(TempEnvVar);
8182
return
8283
string.IsNullOrEmpty(path) ? DefaultTempPath :
8384
PathInternal.IsDirectorySeparator(path[path.Length - 1]) ? path :
@@ -103,7 +104,7 @@ public static string GetTempFileName()
103104
return Encoding.UTF8.GetString(name, 0, name.Length - 1); // trim off the trailing '\0'
104105
}
105106

106-
public static bool IsPathRooted(string path)
107+
public static bool IsPathRooted(string? path)
107108
{
108109
if (path == null)
109110
return false;
@@ -119,7 +120,7 @@ public static bool IsPathRooted(ReadOnlySpan<char> path)
119120
/// <summary>
120121
/// Returns the path root or null if path is empty or null.
121122
/// </summary>
122-
public static string GetPathRoot(string path)
123+
public static string? GetPathRoot(string? path)
123124
{
124125
if (PathInternal.IsEffectivelyEmpty(path)) return null;
125126

0 commit comments

Comments
 (0)