Fix nullable annotation on Path.EndsInDirectorySeparator(string) (#78922)
authorStephen Toub <stoub@microsoft.com>
Tue, 29 Nov 2022 04:49:06 +0000 (23:49 -0500)
committerGitHub <noreply@github.com>
Tue, 29 Nov 2022 04:49:06 +0000 (23:49 -0500)
src/libraries/Common/src/System/IO/PathInternal.cs
src/libraries/System.Private.CoreLib/src/System/IO/Path.cs
src/libraries/System.Runtime/ref/System.Runtime.cs

index dc76d53..c6ea2e2 100644 (file)
@@ -224,7 +224,7 @@ namespace System.IO
         /// <summary>
         /// Returns true if the path ends in a directory separator.
         /// </summary>
-        internal static bool EndsInDirectorySeparator(string? path) =>
+        internal static bool EndsInDirectorySeparator([NotNullWhen(true)] string? path) =>
               !string.IsNullOrEmpty(path) && IsDirectorySeparator(path[path.Length - 1]);
 
         /// <summary>
index aca0272..e7cab2f 100644 (file)
@@ -989,6 +989,6 @@ namespace System.IO
         /// <summary>
         /// Returns true if the path ends in a directory separator.
         /// </summary>
-        public static bool EndsInDirectorySeparator(string path) => PathInternal.EndsInDirectorySeparator(path);
+        public static bool EndsInDirectorySeparator([NotNullWhen(true)] string? path) => PathInternal.EndsInDirectorySeparator(path);
     }
 }
index 713acb7..80966d4 100644 (file)
@@ -9681,8 +9681,8 @@ namespace System.IO
         public static string Combine(string path1, string path2, string path3, string path4) { throw null; }
         public static string Combine(params string[] paths) { throw null; }
         public static bool EndsInDirectorySeparator(System.ReadOnlySpan<char> path) { throw null; }
-        public static bool EndsInDirectorySeparator(string path) { throw null; }
-        public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] string? path) { throw null; }
+        public static bool EndsInDirectorySeparator([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? path) { throw null; }
+        public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? path) { throw null; }
         public static System.ReadOnlySpan<char> GetDirectoryName(System.ReadOnlySpan<char> path) { throw null; }
         public static string? GetDirectoryName(string? path) { throw null; }
         public static System.ReadOnlySpan<char> GetExtension(System.ReadOnlySpan<char> path) { throw null; }