diff --git a/README.md b/README.md index 030df93d0f..e8db1875c3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,16 @@ This repository contains the conceptual documentation for .NET Multi-platform App UI (MAUI). It's published at the [.NET MAUI documentation site](https://learn.microsoft.com/dotnet/maui). +## LLMS Files + +This repo includes curated `llms.txt` files for AI-friendly documentation discovery. + +- Use [docs/llms.txt](docs/llms.txt) for top-level routing across the MAUI docs set. +- Use subtopic `llms.txt` files when the question is scoped to one area such as fundamentals, user interface, platform integration, data, or deployment. +- Use nested `llms.txt` files for higher-signal retrieval in busy areas such as data binding, Shell, controls, handlers, and CollectionView. +- Use [docs/llms-full.txt](docs/llms-full.txt) only when a tool needs one broader context file and cannot follow subtopic links. +- Validate changes with `./docs/tools/verify-llms.ps1`. + ## Code of Conduct This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). diff --git a/docs/data-cloud/llms.txt b/docs/data-cloud/llms.txt new file mode 100644 index 0000000000..50dbdb20bf --- /dev/null +++ b/docs/data-cloud/llms.txt @@ -0,0 +1,30 @@ +# .NET MAUI Data and Cloud + +> Data access patterns for MAUI apps, including REST services, local SQLite persistence, local development services, and push notifications. + +Use this index for app data flow between local storage and networked services. + +Use this file when the question is about API access, local persistence, backend connectivity, or how app state moves between on-device storage and remote systems. + +## Guidance for AI assistants + +- Prefer HttpClient-based REST patterns and DI-managed services for backend access. +- Use SQLite when the app needs structured local relational storage. +- Separate local development backend setup from production deployment guidance. +- Treat push notifications as platform-aware integration work, not just a generic messaging feature. + +## Core data access + +- [Consume REST web services](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/data-cloud/rest.md): HttpClient patterns, serialization, and API integration. +- [Local SQLite databases](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/data-cloud/database-sqlite.md): Local relational data storage with SQLite. +- [Local web services](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/data-cloud/local-web-services.md): Configure local API backends for development. + +## Cloud and messaging + +- [Push notifications](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/data-cloud/push-notifications.md): Notification integration across platforms. +- [Aspire integration](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/data-cloud/aspire-integration.md): Connect MAUI with .NET Aspire-based backends. + +## Optional + +- [Platform integration overview](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/platform-integration/index.md): Related device and platform APIs often used with data apps. +- [Dependency injection](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/fundamentals/dependency-injection.md): Service registration for repositories and API clients. diff --git a/docs/deployment/llms.txt b/docs/deployment/llms.txt new file mode 100644 index 0000000000..71fd11c8b0 --- /dev/null +++ b/docs/deployment/llms.txt @@ -0,0 +1,39 @@ +# .NET MAUI Deployment and Performance + +> Build, publish, trim, and optimize MAUI apps for Android, iOS, Mac Catalyst, and Windows. + +Use this index for shipping and performance hardening scenarios. + +Use this file when the question is about startup time, app size, trimming, AOT, test strategy, or packaging apps for stores and devices. + +## Guidance for AI assistants + +- Measure first when diagnosing performance; do not guess. +- Treat compiled bindings, layout simplification, and correct control choice as the first performance levers. +- Recommend trimming and Native AOT only when code and dependencies are compatible. +- Verify publishing guidance against the target platform rather than assuming Android, iOS, and Windows behave the same way. + +## Performance and optimization + +- [Performance best practices](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/performance-best-practices.md): Actionable guidance for bindings, layouts, images, startup, threading, and memory. +- [Improve app performance](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/performance.md): Performance concepts and measurement strategy. +- [Trimming](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/trimming.md): Reduce app size by removing unused code. +- [Native AOT](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/nativeaot.md): Ahead-of-time compilation guidance and tradeoffs. + +## Build, test, and release + +- [Deployment overview](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/index.md): Cross-platform release flow. +- [Unit testing](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/unit-testing.md): Testing strategy for MAUI applications. +- [Visual Studio project properties](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/deployment/visual-studio-properties.md): Configure packaging and target settings. + +## Platform publishing + +- [Android deployment](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/android/deployment/index.md): Build and publish Android artifacts. +- [iOS deployment](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/ios/deployment/index.md): Build and publish for iOS and TestFlight/App Store. +- [Mac Catalyst deployment](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/mac-catalyst/deployment/index.md): Package and publish Mac Catalyst apps. +- [Windows deployment](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/windows/deployment/overview.md): Package and distribute Windows apps. + +## Optional + +- [Troubleshooting](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/troubleshooting.md): Common issues across build and publish workflows. +- [Supported platforms](https://raw.githubusercontent.com/dotnet/docs-maui/refs/heads/main/docs/supported-platforms.md): Version support constraints that affect shipping decisions. diff --git a/docs/deployment/performance-best-practices.md b/docs/deployment/performance-best-practices.md new file mode 100644 index 0000000000..19d22cddf3 --- /dev/null +++ b/docs/deployment/performance-best-practices.md @@ -0,0 +1,562 @@ +--- +title: "Performance best practices for .NET MAUI" +description: "A practical guide to building high-performance .NET MAUI apps — covering compiled bindings, layout optimization, control selection, image handling, async patterns, startup time, and deployment options." +ms.date: 02/10/2026 +ms.topic: conceptual +--- + +# Performance best practices for .NET MAUI + +This guide covers the most impactful performance optimizations for .NET MAUI apps. Recommendations are ordered roughly by impact — start at the top. + +## 1. Compiled bindings + +This is the single biggest performance win in most MAUI apps. + +### The problem + +Reflection-based bindings resolve property paths at runtime using `System.Reflection`. This adds overhead on every property change notification, every binding evaluation, and every `DataTemplate` instantiation. In a list with hundreds of items, this cost compounds fast. + +### The fix + +Set `x:DataType` on your page and on every `DataTemplate`. This tells the XAML compiler to generate direct property access code at build time instead of using reflection, resulting in 8–20x faster binding resolution. + +```xaml + + + +``` + +```xaml + + + +``` + +Set `x:DataType` on `DataTemplate` elements too — they don't inherit it from the page: + +```xaml + + + + + + +``` + +In C#, use the expression-based `SetBinding` overload for compiled, type-safe bindings: + +```csharp +// DO: Compiled, type-safe — no reflection +label.SetBinding(Label.TextProperty, static (MainViewModel vm) => vm.UserName); + +// DON'T: String-based — uses reflection at runtime +label.SetBinding(Label.TextProperty, "UserName"); +``` + +### Don't bind static values + +If a value never changes and doesn't come from a view model, set it directly. Every binding — even a compiled one — has overhead compared to a direct property assignment. + +```xaml + +