Skip to content

Commit 3a4ba58

Browse files
authored
Fix Path.Join argument nullable annotation (dotnet#24719)
1 parent 41239fe commit 3a4ba58

File tree

1 file changed

+4
-5
lines changed
  • src/System.Private.CoreLib/shared/System/IO

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public static string Join(string? path1, string? path2, string? path3, string? p
468468
return Join(path1.AsSpan(), path2.AsSpan(), path3.AsSpan(), path4.AsSpan());
469469
}
470470

471-
public static string Join(params string[] paths)
471+
public static string Join(params string?[] paths)
472472
{
473473
if (paths == null)
474474
{
@@ -481,7 +481,7 @@ public static string Join(params string[] paths)
481481
}
482482

483483
int maxSize = 0;
484-
foreach (string path in paths)
484+
foreach (string? path in paths)
485485
{
486486
maxSize += path?.Length ?? 0;
487487
}
@@ -493,13 +493,12 @@ public static string Join(params string[] paths)
493493

494494
for (int i = 0; i < paths.Length; i++)
495495
{
496-
if ((paths[i]?.Length ?? 0) == 0)
496+
string? path = paths[i];
497+
if (path == null || path.Length == 0)
497498
{
498499
continue;
499500
}
500501

501-
string path = paths[i];
502-
503502
if (builder.Length == 0)
504503
{
505504
builder.Append(path);

0 commit comments

Comments
 (0)