maui-accessibility
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
Guidance for file picker, file system helpers, bundled assets, and app data storage in .NET MAUI applications. Covers FilePicker APIs, FileResult handling, platform permissions, and common pitfalls across Android, iOS, macOS, and Windows. USE FOR: "file picker", "FilePicker",
$ npx -y skills add davidortinau/maui-skills --skill maui-file-handling --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/maui-file-handlingContext preview
The summary Claude sees to decide when to auto-load this skill.
Guidance for file picker, file system helpers, bundled assets, and app data storage in .NET MAUI applications. Covers FilePicker APIs, FileResult handling, platform permissions, and common pitfalls across Android, iOS, macOS, and Windows. USE FOR: "file picker", "FilePicker",
name: maui-file-handling description: > Guidance for file picker, file system helpers, bundled assets, and app data storage in .NET MAUI applications. Covers FilePicker APIs, FileResult handling, platform permissions, and common pitfalls across Android, iOS, macOS, and Windows. USE FOR: "file picker", "FilePicker", "pick file", "open file", "save file", "bundled assets", "FileSystem helpers", "AppDataDirectory", "CacheDirectory", "FileResult", "read file MAUI". DO NOT USE FOR: media capture or photo picking (use maui-media-picker), secure credential storage (use maui-secure-storage), or SQLite database files (use maui-sqlite-database).
Some platforms (especially Android) return **content URIs**, not file system paths. Reading `FullPath` directly will throw or return empty data.
// ❌ Breaks on Android — FullPath may be a content:// URI
var result = await FilePicker.Default.PickAsync();
var bytes = File.ReadAllBytes(result.FullPath);
// ✅ Works on all platforms
var result = await FilePicker.Default.PickAsync();
if (result is not null)
{
using var stream = await result.OpenReadAsync();
// process stream
}---
Each platform uses a **different format** for custom `FilePickerFileType`. Mixing them up causes the picker to show no files or crash.
| Platform | Format | Example | |---|---|---| | Android | MIME types | `"application/json"` | | iOS / macOS | UTType identifiers | `"public.json"` | | Windows | Dot-prefixed extensions | `".json"` |
// ❌ Using file extensions for Android — picker shows nothing
{ DevicePlatform.Android, new[] { ".json", ".txt" } }
// ✅ Correct MIME types for Android
{ DevicePlatform.Android, new[] { "application/json", "text/plain" } }---
`Resources/Raw` assets cannot be modified at runtime. Attempting to write throws an exception (or silently fails on some platforms).
// ❌ Trying to write to a bundled file
var path = "data.json"; // inside Resources/Raw
File.WriteAllText(path, newContent); // fails
// ✅ Copy to AppDataDirectory first, then modify
string targetPath = Path.Combine(FileSystem.Current.AppDataDirectory, "data.json");
if (!File.Exists(targetPath))
{
using var source = await FileSystem.Current.OpenAppPackageFileAsync("data.json");
using var dest = File.Create(targetPath);
await source.CopyToAsync(dest);
}
// Now safe to read/write targetPathOn some platforms, `Resources/Raw/subdir/file.txt` becomes just `file.txt`. Use **unique file names** regardless of subdirectory structure.
The iOS sandbox path includes an app GUID that changes across clean builds. Hard-coded absolute paths break silently.
// ❌ Hard-coded path — breaks after clean rebuild var path = "/var/mobile/.../Documents/data.json"; // ✅ Always use the FileSystem helper var path = Path.Combine(FileSystem.Current.AppDataDirectory, "data.json");
`OpenAppPackageFileAsync` may return a stream where `.Length` throws `NotSupportedException`. Copy to a `MemoryStream` if you need the size.
// ❌ Throws on Android
using var stream = await FileSystem.Current.OpenAppPackageFileAsync("data.json");
var size = stream.Length; // NotSupportedException
// ✅ Copy first if you need the length
using var stream = await FileSystem.Current.OpenAppPackageFileAsync("data.json");
using var ms = new MemoryStream();
await stream.CopyToAsync(ms);
var size = ms.Length;Packaged apps silently redirect writes to classic paths like `%AppData%`. Always use `AppDataDirectory` and `CacheDirectory` for reliable cross-platform paths.
// ❌ NullReferenceException when user cancels var result = await FilePicker.Default.PickAsync(); using var stream = await result.OpenReadAsync(); // ✅ Always null-check var result = await FilePicker.Default.PickAsync(); if (result is null) return; using var stream = await result.OpenReadAsync();
---
Android 13 replaced `READ_EXTERNAL_STORAGE` with granular media permissions. Using the old permission on API 33+ silently grants nothing.
| Android version | Required permission | |---|---| | ≤ 12 (API 32) | `READ_EXTERNAL_STORAGE` | | ≥ 13 (API 33) | `READ_MEDIA_IMAGES`, `READ_MEDIA_VIDEO`, `READ_MEDIA_AUDIO` |
---
A collection of 41 skills for .NET MAUI development, UI/UX design reasoning, and Xamarin migration, designed for use with GitHub Copilot CLI and Claude Code.
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
.NET MAUI view animations, custom animations, easing functions, rotation, scale, translation, and fade effects. USE FOR: "animate…
.NET MAUI app icon configuration, splash screen setup, SVG to PNG conversion at build time, composed/adaptive icons, and…
.NET MAUI app lifecycle guidance covering the four app states (not running, running, deactivated, stopped), cross-platform Window…
Guide for .NET MAUI apps consuming .NET Aspire-hosted backend services. Covers AppHost configuration, service discovery for…
Add authentication to .NET MAUI apps. Covers WebAuthenticator for generic OAuth 2.0 / social login, and MSAL.NET for Microsoft…