{"record":{"id":"b9fb35a6573a26d3","repo":"QL-Win/QuickLook","slug":"no-icons-in-icns-file","errorCode":null,"errorMessage":"No icons in ICNS file","messagePattern":"No icons in ICNS file","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/IcnsProvider.cs","lineNumber":560,"sourceCode":"        IcnsElement[] icnsElements = new IcnsElement[icnsElementList.Count];\n        for (int i = 0; i < icnsElements.Length; i++)\n            icnsElements[i] = icnsElementList[i];\n\n        return icnsElements;\n    }\n\n    public static IcnsImage GetImage(string filename)\n    {\n        using (var stream = new FileStream(filename, FileMode.Open))\n            return GetImage(stream);\n    }\n\n    public static IcnsImage GetImage(Stream stream)\n    {\n        IcnsElement[] icnsContents = ReadImage(stream);\n        IcnsImage[] result = IcnsDecoder.DecodeAllImages(icnsContents);\n        if (result.Length <= 0)\n            throw new NotSupportedException(\"No icons in ICNS file\");\n\n        IcnsImage max = null;\n        foreach (IcnsImage bitmap in result)\n            if (bitmap.Bitmap != null && (max == null || (bitmap.Bitmap.Width > bitmap.Bitmap.Height)))\n                max = bitmap;\n\n        return max;\n    }\n\n    public static IcnsImage[] GetImages(string filename)\n    {\n        using (var stream = new FileStream(filename, FileMode.Open))\n            return GetImages(stream);\n    }\n\n    public static IcnsImage[] GetImages(Stream stream)\n    {\n        IcnsElement[] icnsContents = ReadImage(stream);","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/IcnsProvider.cs#L542-L578","documentation":"Thrown by IcnsDecoder.GetImage(Stream) after ReadImage and DecodeAllImages when the result array is empty (result.Length <= 0). It means the ICNS container was readable but contained zero decodable icons, so there is nothing to display. NotSupportedException signals an effectively empty/iconless ICNS.","triggerScenarios":"ReadImage returns elements, but DecodeAllImages skips/throws on every one (e.g. all entries are unsupported types caught internally, or all decode failures were swallowed), yielding an empty list; or the file parsed as ICNS but had no icon elements at all.","commonSituations":"An ICNS that lists only icon type codes this decoder cannot handle; a file with a valid 'icns' header but no 'icon' sub-elements; all icons discarded during decoding due to upstream exceptions.","solutions":["Inspect DecodeAllImages to see whether icons are being skipped (unsupported type) vs. truly absent; if skipped, add support for those type codes.","Open the ICNS in a known-good viewer (Preview/macOS Finder); if it also shows nothing, the file is empty.","Re-generate the ICNS from source images with iconutil so it contains standard icon entries.","Catch NotSupportedException at the plugin boundary and report 'no icons found' gracefully."],"exampleFix":"// before\nIcnsImage[] result = IcnsDecoder.DecodeAllImages(icnsContents);\nif (result.Length <= 0)\n    throw new NotSupportedException(\"No icons in ICNS file\");\n\n// after — surface a typed, recoverable result\nif (result.Length <= 0)\n    return null; // caller decides how to present 'empty icon set'","handlingStrategy":"validation","validationCode":"var images = IcnsDecoder.DecodeAllImages(icnsContents);\nif (images.Length == 0) { /* report 'no decodable icons', don't call GetImage's throw path */ }","typeGuard":null,"tryCatchPattern":"try { var img = IcnsDecoder.GetImage(stream); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"No icons\")) { /* empty ICNS */ }","preventionTips":["Check DecodeAllImages().Length before assuming an icon exists.","Inspect why icons are skipped (unsupported types) and add support or re-export.","Validate the ICNS in a known-good viewer before relying on it."],"tags":["icns","macos","icon","empty-result"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}