Skip to content

Commit

Permalink
Improve nullability annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Nov 9, 2023
1 parent 772c3ed commit 9a1dc32
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Zio/FileSystemEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public override string ToString()
}

/// <inheritdoc />
public bool Equals(FileSystemEntry other)
public bool Equals(FileSystemEntry? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
Expand Down
9 changes: 4 additions & 5 deletions src/Zio/FileSystems/MemoryFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ protected override IEnumerable<UPath> EnumeratePathsImpl(UPath path, string sear
// and the time we are going to actually visit it, it might have been
// removed in the meantime, so we make sure here that we have a folder
// and we don't throw an error if it is not
if (!(result.Node is DirectoryNode))
if (result.Node is not DirectoryNode)
{
continue;
}
Expand Down Expand Up @@ -885,7 +885,7 @@ protected override IEnumerable<FileSystemItem> EnumerateItemsImpl(UPath path, Se
// and the time we are going to actually visit it, it might have been
// removed in the meantime, so we make sure here that we have a folder
// and we don't throw an error if it is not
if (!(result.Node is DirectoryNode))
if (result.Node is not DirectoryNode)
{
continue;
}
Expand Down Expand Up @@ -1106,8 +1106,7 @@ void AssertNoDestination(FileSystemNode node)
}
}


private void ValidateDirectory([NotNull] FileSystemNode? node, UPath srcPath)
private static void ValidateDirectory([NotNull] FileSystemNode? node, UPath srcPath)
{
if (node is FileNode)
{
Expand All @@ -1120,7 +1119,7 @@ private void ValidateDirectory([NotNull] FileSystemNode? node, UPath srcPath)
}
}

private void ValidateFile([NotNull] FileSystemNode? node, UPath srcPath)
private static void ValidateFile([NotNull] FileSystemNode? node, UPath srcPath)
{
if (node is null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Zio/FileSystems/MountFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public MountFileSystem(bool owned = true) : this(null, owned)
/// Initializes a new instance of the <see cref="MountFileSystem"/> class with a default backup filesystem.
/// </summary>
/// <param name="defaultBackupFileSystem">The default backup file system.</param>
/// <param name="owned">True if <paramref name="defaultBackupFileSystem"/> and mounted filesytems should be disposed when this instance is disposed.</param>
/// <param name="owned">True if <paramref name="defaultBackupFileSystem"/> and mounted filesystems should be disposed when this instance is disposed.</param>
public MountFileSystem(IFileSystem? defaultBackupFileSystem, bool owned = true) : base(defaultBackupFileSystem, owned)
{
_mounts = new SortedList<UPath, IFileSystem>(new UPathLengthComparer());
Expand Down Expand Up @@ -144,7 +144,7 @@ public IFileSystem Unmount(UPath name)
{
ValidateMountName(name);

IFileSystem mountFileSystem;
IFileSystem? mountFileSystem;

if (!_mounts.TryGetValue(name, out mountFileSystem))
{
Expand Down Expand Up @@ -1011,7 +1011,7 @@ private static UPath CombinePrefix(UPath prefix, UPath remaining)
: prefix / remaining.ToRelative();
}

private void ValidateMountName(UPath name)
private static void ValidateMountName(UPath name)
{
name.AssertAbsolute(nameof(name));
if (name == UPath.Root)
Expand Down
2 changes: 1 addition & 1 deletion src/Zio/UPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public bool Equals(UPath other)
}

/// <inheritdoc />
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is UPath path && Equals(path);
}
Expand Down

0 comments on commit 9a1dc32

Please sign in to comment.