diff --git a/src/libraries/System.IO.FileSystem/ref/System.IO.FileSystem.cs b/src/libraries/System.IO.FileSystem/ref/System.IO.FileSystem.cs index c1790b0658ce64..64c2bbc309368e 100644 --- a/src/libraries/System.IO.FileSystem/ref/System.IO.FileSystem.cs +++ b/src/libraries/System.IO.FileSystem/ref/System.IO.FileSystem.cs @@ -23,7 +23,7 @@ public static void Delete(string path, bool recursive) { } public static System.Collections.Generic.IEnumerable EnumerateFileSystemEntries(string path, string searchPattern) { throw null; } public static System.Collections.Generic.IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, System.IO.EnumerationOptions enumerationOptions) { throw null; } public static System.Collections.Generic.IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, System.IO.SearchOption searchOption) { throw null; } - public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] string? path) { throw null; } + public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? path) { throw null; } public static System.DateTime GetCreationTime(string path) { throw null; } public static System.DateTime GetCreationTimeUtc(string path) { throw null; } public static string GetCurrentDirectory() { throw null; } @@ -126,7 +126,7 @@ public static void Decrypt(string path) { } public static void Delete(string path) { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void Encrypt(string path) { } - public static bool Exists(string? path) { throw null; } + public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? path) { throw null; } public static System.IO.FileAttributes GetAttributes(string path) { throw null; } public static System.DateTime GetCreationTime(string path) { throw null; } public static System.DateTime GetCreationTimeUtc(string path) { throw null; } diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs index 4139de67fb83b9..3d02ebd98a6beb 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs @@ -2,8 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.IO; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Linq; #if MS_IO_REDIST @@ -49,7 +50,7 @@ public static DirectoryInfo CreateDirectory(string path) } // Tests if the given path refers to an existing DirectoryInfo on disk. - public static bool Exists(string? path) + public static bool Exists([NotNullWhen(true)] string? path) { try {