maui-platform-invoke

Abstract platform-specific native API calls in .NET MAUI applications.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/snailb1007/snail-codex-skills --skill maui-platform-invoke-snailb1007
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-platform-invoke
Source: https://github.com/snailb1007/snail-codex-skills/tree/main/skills/maui-platform-invoke
Command: npx skills add https://github.com/snailb1007/snail-codex-skills --skill maui-platform-invoke-snailb1007

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Navigating cross-platform native API access in .NET MAUI apps can lead to scattered platform-specific code, tangled conditional compilation, and brittle DI wiring. This skill provides structured guidance to centralize and simplify these patterns, helping teams build maintainable multi-platform solutions.

Core Features & Use Cases

  • Partial classes and Platforms/ folders to isolate platform-specific implementations while sharing common contracts.
  • Conditional compilation and multi-targeting strategies to cleanly switch behavior per platform.
  • Dependency injection patterns to register platform-specific services and enable testability.
  • Use Case: Build a cross-platform device services layer that hides platform differences from the shared UI code.

Quick Start

Create platform-specific implementations under Platforms/ for each target and wire them into DI in MauiProgram.

Frequently Asked Questions about maui-platform-invoke

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call platform-native APIs in .NET MAUI without scattering conditional code?

To call platform-native APIs in .NET MAUI, use partial classes for shared contracts and place platform implementations under the Platforms/ folder. This isolates platform-specific code while maintaining a unified API surface.

What is the best way to structure cross-platform device services in MAUI?

The best way to structure cross-platform device services in MAUI is using multi-targeting with partial classes. Implement platform-specific logic under Platforms/, then wire these implementations into Dependency Injection in MauiProgram.

Can I use conditional compilation for platform-specific behavior in MAUI?

Yes, you can use conditional compilation in MAUI for minimal inline checks and fallback behavior. However, for full implementations, prefer isolating code in Platforms/ folders to avoid tangled #if blocks in shared code.

How do I register platform-specific implementations in MAUI Dependency Injection?

You register platform-specific implementations in MAUI Dependency Injection by configuring the shared partial class interfaces in MauiProgram. This centralizes DI wiring and enables testability across Android, iOS, Mac Catalyst, and Windows.

Does MAUI multi-targeting support Android, iOS, Mac Catalyst, and Windows simultaneously?

Yes, MAUI multi-targeting supports Android, iOS, Mac Catalyst, and Windows simultaneously. It uses the Platforms/ folder structure to compile platform-specific code natively per target framework without runtime overhead.