Skip to content

Commit

Permalink
File.Exists() is not null when true (#44310)
Browse files Browse the repository at this point in the history
* File.Exists() is not null when true

* Fix compile

* Fix compile 2
  • Loading branch information
iSazonov authored Nov 5, 2020
1 parent ce4772d commit 9e4ac8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void Delete(string path, bool recursive) { }
public static System.Collections.Generic.IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern) { throw null; }
public static System.Collections.Generic.IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, System.IO.EnumerationOptions enumerationOptions) { throw null; }
public static System.Collections.Generic.IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, System.IO.SearchOption searchOption) { throw null; }
public static bool Exists(string? path) { throw null; }
public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhen(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; }
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/System.IO.FileSystem/src/System/IO/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Runtime.Versioning;
Expand Down Expand Up @@ -114,7 +115,7 @@ public static void Delete(string path)
// given by the specified path exists; otherwise, the result is
// false. Note that if path describes a directory,
// Exists will return true.
public static bool Exists(string? path)
public static bool Exists([NotNullWhen(true)] string? path)
{
try
{
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/System.Private.CoreLib/src/Internal/IO/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Security;
using System.IO;

Expand All @@ -18,7 +19,7 @@ internal static partial class File
// given by the specified path exists; otherwise, the result is
// false. Note that if path describes a directory,
// Exists will return true.
public static bool Exists(string? path)
public static bool Exists([NotNullWhen(true)] string? path)
{
try
{
Expand Down

0 comments on commit 9e4ac8b

Please sign in to comment.