Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Delete in IFileSystem #2072

Merged
merged 5 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Sarif/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,14 @@ public void DeleteDirectory(string path, bool recursive = false)
{
Directory.Delete(path, recursive);
}

/// <summary>
/// Deletes a file from a specified path.
/// </summary>
/// <param name="path">File System path of file to delete</param>
public void DeleteFile(string path)
Copy link
Member

@michaelcfanning michaelcfanning Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeleteFile [](start = 20, length = 10)

Generally, we want these names to match the corresponding system API. In this case, we have a problem: Delete is shared as a name between multiple types. I suggest that we prefix Delete with that enclosing type name. So this method s/be named 'FileDelete' and the one preceding it s/be named 'DirectoryDelete' #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename the method CreateDirectory as well?


In reply to: 496997632 [](ancestors = 496997632)

Copy link
Member

@michaelcfanning michaelcfanning Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, to be consistent,this looks right. I think that also means we need to rename 'Create' to 'FileCreate', since it maps to File.Create? Nice catch!


In reply to: 497004102 [](ancestors = 497004102,496997632)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated both


In reply to: 497005275 [](ancestors = 497005275,497004102,496997632)

{
File.Delete(path);
}
}
}
6 changes: 6 additions & 0 deletions src/Sarif/IFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,11 @@ public interface IFileSystem
/// The name of the empty directory to remove. This directory must be writable and empty.
/// </param>
void DeleteDirectory(string path, bool recursive = false);

/// <summary>
/// Deletes a file from a specified path.
Copy link

@ghost ghost Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deletes [](start = 12, length = 7)

I have been copying this documentation from Microsoft online docs, here: https://docs.microsoft.com/en-us/dotnet/api/system.io.file.delete?view=netcore-3.1

So, summary: "Deletes the specified file.", param: "The name of the file to be deleted. Wildcard characters are not supported." #Closed

/// </summary>
/// <param name="path">File System path of file to delete</param>
void DeleteFile(string path);
}
}