diff --git a/src/MimeMapping/KnownMimeTypes.cs b/src/MimeMapping/KnownMimeTypes.cs index d18b594..54008a7 100644 --- a/src/MimeMapping/KnownMimeTypes.cs +++ b/src/MimeMapping/KnownMimeTypes.cs @@ -7149,7 +7149,7 @@ public static class FileExtensions // Switch-case instead of dictionary since it does the hashing at compile time rather than run time - internal static string LookupType(string type) + internal static string? LookupType(string type) { switch (type) { @@ -10213,7 +10213,7 @@ internal static string LookupType(string type) } // Switch-case instead of dictionary since it does the hashing at compile time rather than run time - internal static string[] LookupMimeType(string mimeType) + internal static string[]? LookupMimeType(string mimeType) { switch (mimeType) { diff --git a/src/MimeMapping/KnownMimeTypes.tt b/src/MimeMapping/KnownMimeTypes.tt index e9c8d33..6bd9fab 100644 --- a/src/MimeMapping/KnownMimeTypes.tt +++ b/src/MimeMapping/KnownMimeTypes.tt @@ -155,7 +155,7 @@ namespace MimeMapping // Switch-case instead of dictionary since it does the hashing at compile time rather than run time - internal static string LookupType(string type) + internal static string? LookupType(string type) { switch (type) { @@ -181,7 +181,7 @@ namespace MimeMapping } // Switch-case instead of dictionary since it does the hashing at compile time rather than run time - internal static string[] LookupMimeType(string mimeType) + internal static string[]? LookupMimeType(string mimeType) { switch (mimeType) { diff --git a/src/MimeMapping/MimeMapping.csproj b/src/MimeMapping/MimeMapping.csproj index d871b31..f0b2313 100644 --- a/src/MimeMapping/MimeMapping.csproj +++ b/src/MimeMapping/MimeMapping.csproj @@ -3,6 +3,8 @@ netstandard2.0;net462 + enable + latest Constants for (almost) all MIME types and method to determine MIME type from a file name. Contains just over 1000 mime types. diff --git a/src/MimeMapping/MimeUtility.cs b/src/MimeMapping/MimeUtility.cs index 2da12ba..c452cc7 100644 --- a/src/MimeMapping/MimeUtility.cs +++ b/src/MimeMapping/MimeUtility.cs @@ -16,23 +16,23 @@ public static class MimeUtility /// public const string UnknownMimeType = "application/octet-stream"; - private static readonly Lazy> _lazyDictExtensions = new Lazy>( - () => new ReadOnlyDictionary(KnownMimeTypes.ALL_EXTS.Value.ToDictionary(e => e, e => KnownMimeTypes.LookupType(e))) + private static readonly Lazy> _lazyDictExtensions = new Lazy>( + () => new ReadOnlyDictionary(KnownMimeTypes.ALL_EXTS.Value.ToDictionary(e => e, e => KnownMimeTypes.LookupType(e))) ); - private static readonly Lazy> _lazyDictMimeTypes = new Lazy>( - () => new ReadOnlyDictionary(KnownMimeTypes.ALL_MIMETYPES.Value.Distinct().ToDictionary(e => e, e => KnownMimeTypes.LookupMimeType(e))) + private static readonly Lazy> _lazyDictMimeTypes = new Lazy>( + () => new ReadOnlyDictionary(KnownMimeTypes.ALL_MIMETYPES.Value.Distinct().ToDictionary(e => e, e => KnownMimeTypes.LookupMimeType(e))) ); /// /// Dictionary of all available types by extension (lazy loaded on first call) /// - public static ReadOnlyDictionary TypeMap => _lazyDictExtensions.Value; + public static ReadOnlyDictionary TypeMap => _lazyDictExtensions.Value; /// /// Dictionary of all available types by mimetype (lazy loaded on first call) /// - public static ReadOnlyDictionary TypeToExtensionsMap => _lazyDictMimeTypes.Value; + public static ReadOnlyDictionary TypeToExtensionsMap => _lazyDictMimeTypes.Value; /// The file extensions (ex: "zip"), the file name, or file path /// The mime type string, returns "application/octet-stream" if no known type was found @@ -53,7 +53,7 @@ public static string GetMimeMapping(string file) /// The mime type string, e.g. "application/json" /// One or more extensions matching the mime type or null if no match - public static string[] GetExtensions(string mimeType) + public static string[]? GetExtensions(string mimeType) { if (string.IsNullOrEmpty(mimeType)) throw new ArgumentNullException(mimeType);