Skip to content

Commit

Permalink
removed args validations
Browse files Browse the repository at this point in the history
  • Loading branch information
iksi4prs authored and IngvarX committed Nov 2, 2023
1 parent 92afcb2 commit 3330b67
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 25 deletions.
2 changes: 0 additions & 2 deletions src/Camelot.Services.Abstractions/IPathService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public interface IPathService

string GetExtension(string path);

bool IsExtension(string extension);

string RightTrimPathSeparators(string path);

string LeftTrimPathSeparators(string relativePath);
Expand Down
11 changes: 0 additions & 11 deletions src/Camelot.Services/PathService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ public string GetExtension(string path)
return extension.StartsWith(".") ? extension[1..] : extension;
}

public bool IsExtension(string extension)
{
if (string.IsNullOrWhiteSpace(extension))
return false;
if (extension.Contains("."))
return false;
if (extension.Contains(_environmentPathService.GetDirectorySeparator()))
return false;
return true;
}

public string RightTrimPathSeparators(string path) => path == "/" ? path : path.TrimEnd('/').TrimEnd('\\');

public string LeftTrimPathSeparators(string relativePath) => relativePath.TrimStart('/').TrimStart('\\');
Expand Down
5 changes: 0 additions & 5 deletions src/Camelot.ViewModels.Windows/ShellIcons/WindowsIconTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ public static bool IsIconThatRequiresExtract(string fileName, string extension)
{
throw new ArgumentNullException(nameof(extension));
}
if (extension.StartsWith("."))
{
// As per stanards of this project, extension don't have dot prefix.
throw new ArgumentOutOfRangeException(nameof(extension));
}
if (fileName.Contains('?') || fileName.Contains(','))
{
return true; // icon in indexed resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public WindowsShellIconsService(

public ImageModel GetIconForExtension(string extension)
{
if (!_pathService.IsExtension(extension))
if (string.IsNullOrEmpty(extension))
{
throw new ArgumentException(extension, nameof(extension));
}
Expand Down
6 changes: 0 additions & 6 deletions src/Camelot.ViewModels.Windows/WinApi/ShellIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public static string GetIconForExtension(string extension)
throw new ArgumentNullException(nameof(extension));
}

if (extension.StartsWith("."))
{
// As per stanards of this project, extension don't have dot prefix.
throw new ArgumentOutOfRangeException(nameof(extension));
}

// But to work with Windows API, we still need to add dot prefix...
extension = "." + extension;

Expand Down

0 comments on commit 3330b67

Please sign in to comment.