Skip to content

Commit da5b556

Browse files
Merge pull request #2386 from Ollie-Ave/main
ISSUE #2385 - Implementing try get pattern to TryFindFormatByFileExtension(string extension, [NotNullWhen(true)] out IImageFormat? format)
2 parents 6ec1692 + 1ccad09 commit da5b556

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/ImageSharp/Formats/ImageFormatManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ public void AddImageFormat(IImageFormat format)
102102
/// <returns><see langword="true"/> if a match is found; otherwise, <see langword="false"/></returns>
103103
public bool TryFindFormatByFileExtension(string extension, [NotNullWhen(true)] out IImageFormat? format)
104104
{
105-
Guard.NotNullOrWhiteSpace(extension, nameof(extension));
106-
107-
if (extension[0] == '.')
105+
if (!string.IsNullOrWhiteSpace(extension) && extension[0] == '.')
108106
{
109107
extension = extension[1..];
110108
}

0 commit comments

Comments
 (0)