{"record":{"id":"388992b89e9d0010","repo":"unoplatform/uno","slug":"unsupported-ms-appx-target","errorCode":null,"errorMessage":"Unsupported ms-appx target","messagePattern":"Unsupported ms-appx target","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/ImageTests/SvgImageSource_FromMsAppData.xaml.cs","lineNumber":123,"sourceCode":"\t{\n\t\ttry\n\t\t{\n\t\t\tif (ImageElement.Source is not SvgImageSource svgImageSource)\n\t\t\t{\n\t\t\t\tsvgImageSource = new SvgImageSource();\n\t\t\t\tImageElement.Source = svgImageSource;\n\t\t\t}\n\n\t\t\tif (SelectedSource != null)\n\t\t\t{\n\t\t\t\tvar file = await StorageFile.GetFileFromApplicationUriAsync(SelectedSource.Uri);\n\n\t\t\t\tvar targetFolder = SelectedSource.Name switch\n\t\t\t\t{\n\t\t\t\t\t\"Local\" => ApplicationData.Current.LocalFolder,\n\t\t\t\t\t\"Temp\" => ApplicationData.Current.TemporaryFolder,\n\t\t\t\t\t\"Roaming\" => ApplicationData.Current.RoamingFolder,\n\t\t\t\t\t_ => throw new NotSupportedException(\"Unsupported ms-appx target\")\n\t\t\t\t};\n\n\t\t\t\tawait file.CopyAsync(targetFolder, file.Name, NameCollisionOption.ReplaceExisting);\n\n\t\t\t\tsvgImageSource.UriSource = new Uri($\"ms-appdata:///local/{file.Name}\");\n\n\t\t\t\tvar text = await FileIO.ReadTextAsync(file);\n\t\t\t\tusing MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(text));\n\t\t\t\tawait svgImageSource.SetSourceAsync(stream.AsRandomAccessStream());\n\t\t\t}\n\n\t\t\tif (Enum.TryParse(SelectedStretch, out Stretch stretch))\n\t\t\t{\n\t\t\t\tImageElement.Stretch = stretch;\n\t\t\t}\n\n\t\t\tif (double.TryParse(ImageWidth, out var width))\n\t\t\t{","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/ImageTests/SvgImageSource_FromMsAppData.xaml.cs#L105-L141","documentation":"Thrown by the SVG image source sample when copying an ms-appx asset into an application-data folder whose name is not one of 'Local', 'Temp', or 'Roaming'. The switch expression has no arm for other names, so the default throws NotSupportedException.","triggerScenarios":"SelectedSource.Name returns something other than the three known folder keys — e.g. a new entry added to the source list without a matching switch arm, a localized or renamed folder name, or a null/different casing.","commonSituations":"Extending the sample with a new StorageFolder target (e.g. 'LocalCache', 'SharedLocal') and forgetting the switch arm; case mismatch ('local' vs 'Local'); the data model gaining a new enum value.","solutions":["Add a switch arm for the new folder name mapping to ApplicationData.Current.LocalCacheFolder (or the appropriate folder).","Ensure SelectedSource.Name is exactly cased 'Local'/'Temp'/'Roaming'.","If the new target is not an ApplicationData folder, handle it explicitly rather than relying on the default arm."],"exampleFix":"// before\nvar targetFolder = SelectedSource.Name switch\n{\n    \"Local\" => ApplicationData.Current.LocalFolder,\n    \"Temp\" => ApplicationData.Current.TemporaryFolder,\n    \"Roaming\" => ApplicationData.Current.RoamingFolder,\n    _ => throw new NotSupportedException(\"Unsupported ms-appx target\")\n};\n// after\nvar targetFolder = SelectedSource.Name switch\n{\n    \"Local\" => ApplicationData.Current.LocalFolder,\n    \"LocalCache\" => ApplicationData.Current.LocalCacheFolder,\n    \"Temp\" => ApplicationData.Current.TemporaryFolder,\n    \"Roaming\" => ApplicationData.Current.RoamingFolder,\n    var n => throw new NotSupportedException($\"Unsupported ms-appx target: '{n}'\")\n};","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> KnownFolders = new(){\"Local\",\"LocalCache\",\"Temp\",\"Roaming\"};\nif (!KnownFolders.Contains(SelectedSource.Name)) throw new NotSupportedException($\"Unsupported ms-appx target: {SelectedSource.Name}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the switch arms in sync with the source-list model.","Use an enum instead of strings for folder targets to get compile-time exhaustiveness.","Include the offending name in the error message for fast diagnosis."],"tags":["storage","ms-appx","applicationdata","samples","switch"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}