### Troubleshooting Appium Server Startup Source: https://github.com/dotnet/maui/wiki/UITests Provides guidance on troubleshooting issues related to the Appium server not starting. It suggests running the Appium server from the command line to obtain more detailed error messages. ```bash node /usr/local/lib/node_modules/appium/build/lib/main.js ``` -------------------------------- ### Verify .NET SDK and Workloads Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Commands to check the installed .NET SDK version, list all available workloads, and inspect the project's target frameworks. Useful for verifying the development environment setup. ```bash # Verify .NET SDK dotnet --version # List installed workloads dotnet workload list # Check project target frameworks dotnet list reference ``` -------------------------------- ### Build MAUI Templates Script Usage Source: https://github.com/dotnet/maui/blob/main/src/Templates/README.md Example usages of the build.ps1 script for .NET MAUI templates. Demonstrates how to use parameters to customize project type, template version, project path, and whether to start Visual Studio after the build. ```powershell .\build.ps1 -projectType maui-blazor ``` ```powershell .\build.ps1 -templateVersion 1.2.3 ``` ```powershell .\build.ps1 -templatesProjectPath src\Microsoft.Maui.Templates-new.csproj ``` ```powershell .\build.ps1 -startVsAfterBuild $false ``` -------------------------------- ### Installing a Specific MAUI Workload Version (.NET CLI) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Installs a specific version of the MAUI workload, such as a preview version, using the .NET CLI. This allows for testing against non-stable or specific preview releases. ```bash # Example: Install .NET 9 preview workload dotnet workload install maui --version 9.0.100-preview.1 ``` -------------------------------- ### Interactive REPL and Screenshots Source: https://github.com/dotnet/maui/wiki/UITests The REPL method starts an interactive Read-Eval-Print-Loop for debugging and exploration, pausing test execution. The Screenshot method captures the current state of the app and saves it with a given title. ```csharp App.Repl(); App.Screenshot("Sample"); ``` -------------------------------- ### Installing MAUI Workloads with .NET CLI Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Installs the latest stable MAUI workload using the .NET Command Line Interface. This is a prerequisite for compiling MAUI applications using the MAUI Workloads mode. ```bash dotnet workload install maui ``` -------------------------------- ### Install MAUI Workload System-Wide (Windows) Source: https://github.com/dotnet/maui/blob/main/src/Workload/README.md This command installs the .NET MAUI workload system-wide on Windows using an Administrator command prompt. It targets a specific .csproj file responsible for the installation process. ```powershell > dotnet build src/DotNet/DotNet.csproj -t:Install ``` -------------------------------- ### Searching for Available MAUI Workload Versions (.NET CLI) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Searches for available MAUI workload versions using the .NET CLI. This command helps identify which versions can be installed or are currently installed. ```bash dotnet workload search maui ``` -------------------------------- ### Version Tracking API Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt APIs for tracking application installation and launch versions. ```APIDOC ## Version Tracking API ### Description Provides methods to track the first installation, first launch for specific versions or builds, and retrieve version history. ### Methods - **GetFirstInstalledVersion**: Retrieves the version of the application when it was first installed. - **IsFirstLaunchEver**: Checks if this is the very first launch of the application ever. - **IsFirstLaunchForBuild**: Checks if this is the first launch for a specific build string. - **IsFirstLaunchForCurrentBuild**: Checks if this is the first launch for the currently installed build. - **IsFirstLaunchForCurrentVersion**: Checks if this is the first launch for the currently installed version. - **IsFirstLaunchForVersion**: Checks if this is the first launch for a specific version string. - **GetPreviousBuild**: Retrieves the build string of the previous application version. - **GetPreviousVersion**: Retrieves the version string of the previous application version. - **Track**: Records the current application version and launch details. - **GetVersionHistory**: Retrieves a collection of all previously installed application versions. ### Example Usage ```csharp // Check if it's the first launch for the current version if (VersionTracking.IsFirstLaunchForCurrentVersion) { // Perform actions for first launch } // Get the first installed version string? firstInstallVersion = VersionTracking.FirstInstalledVersion; // Track the current launch VersionTracking.Track(); ``` ``` -------------------------------- ### Build .NET MAUI for All Platforms Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Builds a .NET MAUI application targeting all configured platforms. This command assumes all necessary platform SDKs and workloads are installed. ```bash dotnet build ``` -------------------------------- ### Install MAUI Workload System-Wide (macOS) Source: https://github.com/dotnet/maui/blob/main/src/Workload/README.md This command installs the .NET MAUI workload system-wide on macOS. It requires administrator privileges and targets a specific .csproj file responsible for the installation process. ```bash $ sudo dotnet build src/DotNet/DotNet.csproj -t:Install ``` -------------------------------- ### Provisioning Appium Tests (.NET CLI) Source: https://github.com/dotnet/maui/wiki/UITests Builds the provisioning project to prepare for Appium tests. This command is used on both Windows and macOS. It ensures that necessary Appium components are restored and configured. The `-t:ProvisionAppium` target and `-p:SkipAppiumDoctor="true"` parameter are specific to this provisioning process. ```bash dotnet build ./src/Provisioning/Provisioning.csproj -t:ProvisionAppium -p:SkipAppiumDoctor="true" -bl:"./artifacts/logs/provision-appium.binlog" ``` -------------------------------- ### Run MacCatalyst Build and Test using Dotnet Cake Source: https://github.com/dotnet/maui/wiki/DeviceTests Facilitates building and testing .NET MAUI applications for MacCatalyst. It allows separate execution of build-only and test-only targets, specifying the project file and ensuring global workloads are installed. Note the use of mixed path separators in the example. ```bash dotnet cake -script eng/devices/catalyst.cake --target="buildOnly" --project="C:\repos\dotnet\maui\src\Core\tests\DeviceTests\Core.DeviceTests.csproj" --workloads=global dotnet cake -script eng/devices/catalyst.cake --target="testOnly" --project="C:\repos\dotnet\maui\src\Core\tests\DeviceTests\Core.DeviceTests.csproj" --workloads=global dotnet cake -script eng/devices/catalyst.cake --target="buildOnly" --project="C:\repos\dotnet\maui\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj" --workloads=global dotnet cake -script eng/devices/catalyst.cake --target="testOnly" --project="C:\repos\dotnet\maui\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj" --workloads=global ``` -------------------------------- ### Build MAUI Project for Android Target Framework (CLI) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md This command builds a MAUI project specifically targeting the Android platform using the specified .NET framework version. This is an example of building for a single platform. ```bash dotnet build -f net10.0-android ``` -------------------------------- ### Configure .NET MAUI App with MauiProgram.cs Source: https://github.com/dotnet/maui/wiki/Migrating-from-Preview-7-to-8 This snippet demonstrates the standard .NET MAUI application setup using the MauiProgram.cs file, which aligns with the host builder pattern used in ASP.NET and Blazor. It initializes the MauiApp builder and configures application fonts. ```csharp using Microsoft.Maui; using Microsoft.Maui.Hosting; using Microsoft.Maui.Controls.Compatibility; using Microsoft.Maui.Controls.Hosting; namespace MauiApp._1 { public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); }); return builder.Build(); } } } ``` -------------------------------- ### BlazorWebView Static Property Source: https://github.com/dotnet/maui/blob/main/src/BlazorWebView/src/Maui/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt Static property for BlazorWebView related to the start path. ```APIDOC ## BlazorWebView Static Property ### Description Provides static properties for BlazorWebView, including the start path property. ### Static Properties - **StartPathProperty** -> Microsoft.Maui.Controls.BindableProperty! - Description: Represents the bindable property for the start path of the BlazorWebView. ``` -------------------------------- ### Version Tracking API Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net/PublicAPI.Shipped.txt APIs for tracking application versions, including first installation, first launch for specific versions/builds, and version history. ```APIDOC ## Version Tracking API ### Description Provides functionality to track application installation and launch versions. ### Methods - **GET /versionTracking/firstInstalledVersion** - Returns the first installed version of the application. - Returns: `string?` - **GET /versionTracking/isFirstLaunchEver** - Checks if this is the very first launch of the application ever. - Returns: `bool` - **GET /versionTracking/isFirstLaunchForBuild/{build}** - Checks if this is the first launch for a specific build. - Parameters: - `build` (string) - The build identifier. - Returns: `bool` - **GET /versionTracking/isFirstLaunchForCurrentBuild** - Checks if this is the first launch for the current build. - Returns: `bool` - **GET /versionTracking/isFirstLaunchForCurrentVersion** - Checks if this is the first launch for the current version. - Returns: `bool` - **GET /versionTracking/isFirstLaunchForVersion/{version}** - Checks if this is the first launch for a specific version. - Parameters: - `version` (string) - The version identifier. - Returns: `bool` - **GET /versionTracking/previousBuild** - Returns the previous build identifier. - Returns: `string?` - **GET /versionTracking/previousVersion** - Returns the previous version identifier. - Returns: `string?` - **POST /versionTracking/track** - Tracks the current application version and launch. - Returns: `void` - **GET /versionTracking/versionHistory** - Returns a history of all previously installed versions. - Returns: `IEnumerable` ``` -------------------------------- ### Bootstrapping .NET SDK and Launching VS with Cake Source: https://github.com/dotnet/maui/blob/main/docs/DevelopmentTips.md Shows how to use the 'dotnet cake' command with the '--target=VS' parameter to bootstrap the .NET SDK in the 'bin\dotnet' directory and launch Visual Studio. ```dotnetcli dotnet tool restore dotnet cake --target=VS ``` -------------------------------- ### BrowserLaunchOptions Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Shipped.txt Provides options for launching a web browser, including preferred colors, title visibility, and launch mode. ```APIDOC ## BrowserLaunchOptions ### Description Provides options for launching a web browser. ### Method Constructor ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "new BrowserLaunchOptions()" } ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## BrowserLaunchOptions.Flags ### Description Gets or sets flags that control the browser launch behavior. ### Method Getter/Setter ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "browserLaunchOptions.Flags = BrowserLaunchFlags.None;" } ``` ### Response #### Success Response (200) - **Flags** (BrowserLaunchFlags) - Flags that control the browser launch behavior. #### Response Example ```json { "example": "BrowserLaunchFlags.None" } ``` ``` ```APIDOC ## BrowserLaunchOptions.LaunchMode ### Description Gets or sets the launch mode for the browser. ### Method Getter/Setter ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "browserLaunchOptions.LaunchMode = BrowserLaunchMode.External;" } ``` ### Response #### Success Response (200) - **LaunchMode** (BrowserLaunchMode) - The launch mode for the browser. #### Response Example ```json { "example": "BrowserLaunchMode.External" } ``` ``` ```APIDOC ## BrowserLaunchOptions.PreferredControlColor ### Description Gets or sets the preferred color for browser controls. ### Method Getter/Setter ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "browserLaunchOptions.PreferredControlColor = Colors.Blue;" } ``` ### Response #### Success Response (200) - **PreferredControlColor** (Color?) - The preferred color for browser controls. #### Response Example ```json { "example": "#0000FF" } ``` ``` ```APIDOC ## BrowserLaunchOptions.PreferredToolbarColor ### Description Gets or sets the preferred color for the browser's toolbar. ### Method Getter/Setter ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "browserLaunchOptions.PreferredToolbarColor = Colors.Red;" } ``` ### Response #### Success Response (200) - **PreferredToolbarColor** (Color?) - The preferred color for the browser's toolbar. #### Response Example ```json { "example": "#FF0000" } ``` ``` ```APIDOC ## BrowserLaunchOptions.TitleMode ### Description Gets or sets the title mode for the browser. ### Method Getter/Setter ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "browserLaunchOptions.TitleMode = BrowserTitleMode.Show;" } ``` ### Response #### Success Response (200) - **TitleMode** (BrowserTitleMode) - The title mode for the browser. #### Response Example ```json { "example": "BrowserTitleMode.Show" } ``` ``` -------------------------------- ### MAUI Targets Import Example Source: https://github.com/dotnet/maui/blob/main/docs/design/NuGets.md Demonstrates how a NuGet package can inject custom targets to run after the main SDK targets have been processed. This is commonly used for post-build or post-target operations specific to the package. ```xml $(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)Microsoft.Maui.[something].After.targets ``` -------------------------------- ### Initialize SkiaStringSizeService Source: https://github.com/dotnet/maui/blob/main/src/Graphics/src/Graphics.Skia/PublicAPI/net-macos/PublicAPI.Shipped.txt Default constructor for the SkiaStringSizeService. ```csharp public SkiaStringSizeService() ``` -------------------------------- ### Fix MAUI Workload Installation Error on ARM64 Source: https://github.com/dotnet/maui/wiki/Known-Issues Addresses an error where the MAUI workload is not supported on win-arm64 machines during installation. The workaround involves manually patching the WorkloadManifest.json files. This requires understanding the file structure of .NET MAUI installations. ```log Workload ID maui isn't supported on this platform. ``` -------------------------------- ### IWindowOverlay - Initialization and State Management Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt Methods for initializing, deinitializing, and managing the state of the window overlay. ```APIDOC ## POST /windowoverlay/initialize ### Description Initializes the window overlay. ### Method POST ### Endpoint `/windowoverlay/initialize` ### Parameters None ### Response #### Success Response (200) - **Success** (bool) - True if initialization was successful, false otherwise. #### Response Example ```json { "Success": true } ``` ## POST /windowoverlay/deinitialize ### Description Deinitializes the window overlay. ### Method POST ### Endpoint `/windowoverlay/deinitialize` ### Parameters None ### Response #### Success Response (200) - **Success** (bool) - True if deinitialization was successful, false otherwise. #### Response Example ```json { "Success": true } ``` ## POST /windowoverlay/handle-ui-change ### Description Handles UI changes for the window overlay. ### Method POST ### Endpoint `/windowoverlay/handle-ui-change` ### Parameters None ### Response #### Success Response (200) - **Success** (bool) - Indicates if the UI change was handled successfully. #### Response Example ```json { "Success": true } ``` ## POST /windowoverlay/invalidate ### Description Invalidates the window overlay, typically triggering a redraw. ### Method POST ### Endpoint `/windowoverlay/invalidate` ### Parameters None ### Response #### Success Response (200) - **Success** (bool) - Indicates if the invalidation was successful. #### Response Example ```json { "Success": true } ``` ## GET /windowoverlay/is-platform-view-initialized ### Description Checks if the platform view for the window overlay has been initialized. ### Method GET ### Endpoint `/windowoverlay/is-platform-view-initialized` ### Parameters None ### Response #### Success Response (200) - **IsInitialized** (bool) - True if the platform view is initialized, false otherwise. #### Response Example ```json { "IsInitialized": true } ``` ``` -------------------------------- ### MAUI Platform Window Management Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Shipped.txt Handles platform-specific window activation and launch events. ```APIDOC ## MAUI Platform Window Management ### Description Handles platform-specific window activation and launch events, and initializes platform windows. ### Methods - **OnActivated**: Handles window activation events. - `OnActivated(Window window, WindowActivatedEventArgs args)` - **OnLaunched**: Handles application launch events. - `OnLaunched(LaunchActivatedEventArgs e)` - **OnPlatformWindowInitialized**: Called when a platform window is initialized. - `OnPlatformWindowInitialized(Window window)` ### Parameters #### Window - **window** (Window) - Required - The window object. #### WindowActivatedEventArgs - **args** (WindowActivatedEventArgs) - Required - Arguments for the window activation event. #### LaunchActivatedEventArgs - **e** (LaunchActivatedEventArgs) - Required - Arguments for the application launch event. ### Request Body N/A ### Response #### Success Response (200) - **void** - These methods do not return a value. #### Response Example N/A ``` -------------------------------- ### MAUI PropertyMapper Methods Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net/PublicAPI.Shipped.txt Documentation for methods related to MAUI PropertyMapper, including clearing cache, getting keys, getting properties, and setting/updating properties. ```APIDOC ## virtual Microsoft.Maui.PropertyMapper.ClearKeyCache() -> void ### Description Clears the key cache for the property mapper. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## virtual Microsoft.Maui.PropertyMapper.GetKeys() -> System.Collections.Generic.IEnumerable! ### Description Gets all the keys currently stored in the property mapper. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (System.Collections.Generic.IEnumerable!) Returns an enumerable collection of strings representing the keys. #### Response Example N/A ## virtual Microsoft.Maui.PropertyMapper.GetProperty(string! key) -> System.Action? ### Description Retrieves the action associated with a specific key from the property mapper. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (System.Action?) Returns the action if found, otherwise null. #### Response Example N/A ## virtual Microsoft.Maui.PropertyMapper.SetPropertyCore(string! key, System.Action! action) -> void ### Description Sets a property with a given key and action, core implementation. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## virtual Microsoft.Maui.PropertyMapper.UpdateKeys.get -> System.Collections.Generic.IReadOnlyCollection! ### Description Gets a read-only collection of keys that need to be updated. ### Method Virtual Getter ### Endpoint N/A (Property Getter) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (System.Collections.Generic.IReadOnlyCollection!) Returns a read-only collection of strings. #### Response Example N/A ## virtual Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string! key, Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.IElement! virtualView) -> void ### Description Updates a property with the given key, view handler, and virtual view, core implementation. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` -------------------------------- ### Build and Prepare iOS UI Tests (PowerShell) Source: https://github.com/dotnet/maui/wiki/UITests Executes build and prepare scripts for iOS UI tests using PowerShell. The `build.ps1` script with specified targets (`uitest-build`, `uitest-prepare`) and the `ios.cake` device script are used to set up the necessary environment and build artifacts for running tests on iOS simulators or devices. ```powershell ./build.ps1 -Script eng/devices/ios.cake --target=uitest-build ./build.ps1 -Script eng/devices/ios.cake --target=uitest-prepare ``` -------------------------------- ### Platform Initialization and Event Handling Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net-android/PublicAPI.Shipped.txt Provides methods for initializing the MAUI platform on Android and handling platform-specific lifecycle events. ```APIDOC ## Platform Initialization and Event Handling ### Description This section details the platform-specific initialization required for MAUI applications on Android and the handling of various platform-level events and activities. ### Methods - **ActivityStateChanged** - **Method:** static event - **Endpoint:** N/A - **Description:** Event triggered when the activity state changes. - **AppContext.get** - **Method:** static getter - **Endpoint:** N/A - **Description:** Retrieves the Android application context. - **Returns:** `Android.Content.Context` - **CurrentActivity.get** - **Method:** static getter - **Endpoint:** N/A - **Description:** Retrieves the current Android activity. - **Returns:** `Android.App.Activity?` - **Init(Android.App.Activity activity, Android.OS.Bundle bundle)** - **Method:** static - **Endpoint:** N/A - **Description:** Initializes the MAUI platform with the Android activity and bundle. - **Init(Android.App.Application application)** - **Method:** static - **Endpoint:** N/A - **Description:** Initializes the MAUI platform with the Android application. - **OnNewIntent(Android.Content.Intent intent)** - **Method:** static - **Endpoint:** N/A - **Description:** Handles new intents received by the activity. - **OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)** - **Method:** static - **Endpoint:** N/A - **Description:** Callback for permission request results. - **OnResume(Android.App.Activity activity = null)** - **Method:** static - **Endpoint:** N/A - **Description:** Handles the resume event for the Android activity. - **WaitForActivityAsync(System.Threading.CancellationToken cancelToken = default)** - **Method:** static - **Endpoint:** N/A - **Description:** Asynchronously waits for an Android activity to become available. - **Returns:** `System.Threading.Tasks.Task` ``` -------------------------------- ### Start Timer with Dispatcher in .NET MAUI Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt Starts a timer that executes a callback function at regular intervals on the UI thread. The StartTimer method on IDispatcher is used for periodic operations in .NET MAUI. ```csharp static Microsoft.Maui.Dispatching.DispatcherExtensions.StartTimer(this Microsoft.Maui.Dispatching.IDispatcher! dispatcher, System.TimeSpan interval, System.Func! callback) -> void ``` -------------------------------- ### Verify Screenshots Source: https://github.com/dotnet/maui/wiki/UITests This method takes a screenshot and compares it pixel by pixel with a reference screenshot. The reference can be specified by name or defaults to the test name. ```csharp VerifyScreenshot(); ``` -------------------------------- ### Initialize SkiaImageLoadingService Source: https://github.com/dotnet/maui/blob/main/src/Graphics/src/Graphics.Skia/PublicAPI/net-macos/PublicAPI.Shipped.txt Default constructor for the SkiaImageLoadingService. ```csharp public SkiaImageLoadingService() ``` -------------------------------- ### Compiling MAUI Manual Tests with Source Code Mode (Directory.Build.props) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Sets up the MAUI ManualTests project to build from local source code by defining the `UseMaui` property in a `Directory.Build.props` file at the solution root. This ensures the setting is applied consistently across multiple builds. ```xml false ``` -------------------------------- ### Build and Prepare Android UI Tests (PowerShell) Source: https://github.com/dotnet/maui/wiki/UITests Executes build and prepare scripts for Android UI tests using PowerShell. The `build.ps1` script with specified targets (`uitest-build`, `uitest-prepare`) and the `android.cake` device script are used to set up the necessary environment and build artifacts for running tests on Android emulators or devices. ```powershell ./build.ps1 -Script eng/devices/android.cake --target=uitest-build ./build.ps1 -Script eng/devices/android.cake --target=uitest-prepare ``` -------------------------------- ### Add Application Identifier and GUID in .NET MAUI csproj Source: https://github.com/dotnet/maui/wiki/Migrating-to-RC1 This XML snippet illustrates how to add the `ApplicationId` and `ApplicationIdGuid` tags within the .csproj file for .NET MAUI applications. The `ApplicationIdGuid` requires a unique GUID. ```xml com.companyname.mauiapp.MyApp REPLACE-WITH-YOUR-GUID ``` -------------------------------- ### C# Delegate Property Example Source: https://github.com/dotnet/maui/wiki/Memory-Leaks Shows a C# delegate property (Func) within a class. This serves as an example of how holding delegates can create strong references to parent objects, similar to C# events, potentially causing memory leaks. ```csharp public Func? GetValue { get; set; } // Somewhere inside the class, the Func is used int x = GetValue?.Invoke() ?? 0; ``` -------------------------------- ### Initialize SkiaCanvasStateService Source: https://github.com/dotnet/maui/blob/main/src/Graphics/src/Graphics.Skia/PublicAPI/net-macos/PublicAPI.Shipped.txt Default constructor for the SkiaCanvasStateService. ```csharp public SkiaCanvasStateService() ``` -------------------------------- ### MAUI Preferences API Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net/PublicAPI.Shipped.txt APIs for getting, setting, and removing preferences. ```APIDOC ## MAUI Preferences API ### Description Provides methods to store and retrieve key-value pairs of simple data types, including dates and times, with optional shared name support. ### Methods **Get Date/DateTimeOffset Preferences** - **Get(string key, DateTime defaultValue, string? sharedName)**: Retrieves a DateTime value. - **Get(string key, DateTime defaultValue)**: Retrieves a DateTime value without a shared name. - **Get(string key, DateTimeOffset defaultValue, string? sharedName)**: Retrieves a DateTimeOffset value. - **Get(string key, DateTimeOffset defaultValue)**: Retrieves a DateTimeOffset value without a shared name. **Remove Preferences** - **Remove(string key, string? sharedName)**: Removes a preference by key and optional shared name. - **Remove(string key)**: Removes a preference by key. **Set Preferences** - **Set(string key, bool value, string? sharedName)**: Sets a boolean value. - **Set(string key, bool value)**: Sets a boolean value without a shared name. - **Set(string key, double value, string? sharedName)**: Sets a double value. - **Set(string key, double value)**: Sets a double value without a shared name. - **Set(string key, float value, string? sharedName)**: Sets a float value. - **Set(string key, float value)**: Sets a float value without a shared name. - **Set(string key, int value, string? sharedName)**: Sets an integer value. - **Set(string key, int value)**: Sets an integer value without a shared name. - **Set(string key, long value, string? sharedName)**: Sets a long value. - **Set(string key, long value)**: Sets a long value without a shared name. - **Set(string key, string? value, string? sharedName)**: Sets a string value. - **Set(string key, string? value)**: Sets a string value without a shared name. - **Set(string key, DateTime value, string? sharedName)**: Sets a DateTime value. - **Set(string key, DateTime value)**: Sets a DateTime value without a shared name. - **Set(string key, DateTimeOffset value, string? sharedName)**: Sets a DateTimeOffset value. - **Set(string key, DateTimeOffset value)**: Sets a DateTimeOffset value without a shared name. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Example for setting a string preference Microsoft.Maui.Storage.Preferences.Set("Username", "JohnDoe"); // Example for getting a boolean preference bool isActive = Microsoft.Maui.Storage.Preferences.Get("IsActive", false); ``` ### Response #### Success Response (void/bool/value type) - **void**: Indicates successful operation for Set/Remove. - **bool**: Indicates if the removal was successful for Remove. - **value type**: The retrieved value for Get operations. #### Response Example ```json // No specific JSON response, operations return void, bool, or the retrieved value. ``` ``` -------------------------------- ### Launcher API Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt Enables opening external applications and URLs. ```APIDOC ## Launcher API ### Description This API provides functionality to check if a URI can be opened and to open URIs using the device's default applications. ### Methods #### CanOpenAsync (String URI) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (string) - Required - The URI to check if it can be opened. * **Response:** * **Task** - A task that returns true if the URI can be opened, false otherwise. #### CanOpenAsync (Uri Object) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (Uri) - Required - The URI to check if it can be opened. * **Response:** * **Task** - A task that returns true if the URI can be opened, false otherwise. #### OpenAsync (OpenFileRequest) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **request** (OpenFileRequest) - Required - A request object containing details for opening a file. * **Response:** * **Task** - A task that returns true if the file was opened successfully, false otherwise. #### OpenAsync (String URI) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (string) - Required - The URI to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. #### OpenAsync (Uri Object) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (Uri) - Required - The URI to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. #### TryOpenAsync (String URI) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (string) - Required - The URI to attempt to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. #### TryOpenAsync (Uri Object) * **Method:** static * **Endpoint:** N/A (This is a method call) * **Parameters:** * **uri** (Uri) - Required - The URI to attempt to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. #### CanOpenAsync (Extension Method) * **Method:** static (extension method) * **Endpoint:** N/A (This is a method call) * **Parameters:** * **launcher** (ILauncher) - Required - The instance of the ILauncher interface. * **uri** (string) - Required - The URI to check if it can be opened. * **Response:** * **Task** - A task that returns true if the URI can be opened, false otherwise. #### OpenAsync (Extension Method) * **Method:** static (extension method) * **Endpoint:** N/A (This is a method call) * **Parameters:** * **launcher** (ILauncher) - Required - The instance of the ILauncher interface. * **uri** (string) - Required - The URI to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. #### TryOpenAsync (Extension Method) * **Method:** static (extension method) * **Endpoint:** N/A (This is a method call) * **Parameters:** * **launcher** (ILauncher) - Required - The instance of the ILauncher interface. * **uri** (string) - Required - The URI to attempt to open. * **Response:** * **Task** - A task that returns true if the URI was opened successfully, false otherwise. ``` -------------------------------- ### Compiling MAUI Manual Tests with MAUI Workloads (.NET CLI) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md Compiles the MAUI ManualTests project using installed MAUI workloads. This mode is suitable for standard app development and uses officially released MAUI versions. Requires specifying `UseMaui=true` and the correct `MauiVersion`. ```bash # Standard build (replace with your installed workload version, e.g., 10.0.0) dotnet build -p:UseMaui=true -p:MauiVersion= # Restore packages first (recommended) dotnet restore -p:UseMaui=true -p:MauiVersion= dotnet build -p:UseMaui=true -p:MauiVersion= # Build for specific platform dotnet build -p:UseMaui=true -p:MauiVersion= -f net10.0-android dotnet build -p:UseMaui=true -p:MauiVersion= -f net10.0-ios ``` -------------------------------- ### Search for MAUI Package Versions (NuGet CLI) Source: https://github.com/dotnet/maui/blob/main/src/Controls/tests/ManualTests/README.md This command uses the NuGet CLI to list all available versions of the 'Microsoft.Maui.Controls' package, including pre-release versions. This is useful for finding specific nightly or preview builds. ```bash nuget list Microsoft.Maui.Controls -AllVersions -PreRelease ``` -------------------------------- ### Navigate Back in .NET MAUI Appium Source: https://github.com/dotnet/maui/wiki/UITests Navigates the application back to the previous screen. This is a fundamental navigation action in UI testing. ```csharp public void Back (); ``` -------------------------------- ### Window Properties Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt APIs to get and set properties of the MAUI window, such as dimensions and position. ```APIDOC ## GET /window/dimensions ### Description Retrieves the current width and height of the MAUI window. ### Method GET ### Endpoint /window/dimensions ### Parameters None ### Request Example None ### Response #### Success Response (200) - **width** (double) - The current width of the window. - **height** (double) - The current height of the window. #### Response Example ```json { "width": 800.0, "height": 600.0 } ``` ## GET /window/position ### Description Retrieves the current X and Y coordinates of the MAUI window's top-left corner. ### Method GET ### Endpoint /window/position ### Parameters None ### Request Example None ### Response #### Success Response (200) - **x** (double) - The current X coordinate of the window. - **y** (double) - The current Y coordinate of the window. #### Response Example ```json { "x": 100.0, "y": 50.0 } ``` ``` -------------------------------- ### MAUI WindowOverlay Methods Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net/PublicAPI.Shipped.txt Documentation for methods in the WindowOverlay class, including adding/removing elements, initialization, and handling UI changes. ```APIDOC ## virtual Microsoft.Maui.WindowOverlay.AddWindowElement(Microsoft.Maui.IWindowOverlayElement! drawable) -> bool ### Description Adds a drawable window element to the overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (bool) Returns true if the element was added successfully, false otherwise. #### Response Example N/A ## virtual Microsoft.Maui.WindowOverlay.Deinitialize() -> bool ### Description Deinitializes the window overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (bool) Returns true if deinitialization was successful, false otherwise. #### Response Example N/A ## virtual Microsoft.Maui.WindowOverlay.HandleUIChange() -> void ### Description Handles changes in the user interface related to the window overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## virtual Microsoft.Maui.WindowOverlay.Initialize() -> bool ### Description Initializes the window overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (bool) Returns true if initialization was successful, false otherwise. #### Response Example N/A ## virtual Microsoft.Maui.WindowOverlay.RemoveWindowElement(Microsoft.Maui.IWindowOverlayElement! drawable) -> bool ### Description Removes a specific drawable window element from the overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (bool) Returns true if the element was removed successfully, false otherwise. #### Response Example N/A ## virtual Microsoft.Maui.WindowOverlay.RemoveWindowElements() -> void ### Description Removes all drawable window elements from the overlay. ### Method Virtual ### Endpoint N/A (Method Signature) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` -------------------------------- ### IVersionTracking API Source: https://github.com/dotnet/maui/blob/main/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Shipped.txt Tracks application version and build history for the first launch experience. ```APIDOC ## IVersionTracking API ### Description Tracks application version and build history for the first launch experience. ### Properties - **BuildHistory** (System.Collections.Generic.IReadOnlyList) - Gets a read-only list of all recorded build numbers. - **CurrentBuild** (string) - Gets the current build number of the application. - **CurrentVersion** (string) - Gets the current version of the application. - **FirstInstalledBuild** (string?) - Gets the build number of the first installation, or null if not set. - **FirstInstalledVersion** (string?) - Gets the version string of the first installation, or null if not set. - **IsFirstLaunchEver** (bool) - Gets a value indicating if this is the first launch ever for the application. - **IsFirstLaunchForBuild(string build)** - bool - Checks if it's the first launch for a specific build number. - **IsFirstLaunchForCurrentBuild** (bool) - Gets a value indicating if this is the first launch for the current build. - **IsFirstLaunchForCurrentVersion** (bool) - Gets a value indicating if this is the first launch for the current version. - **IsFirstLaunchForVersion(string version)** - bool - Checks if it's the first launch for a specific version. - **PreviousBuild** (string?) - Gets the previous build number, or null if not set. - **PreviousVersion** (string?) - Gets the previous version string, or null if not set. - **VersionHistory** (System.Collections.Generic.IReadOnlyList) - Gets a read-only list of all recorded version strings. ### Method - **Track()** - void - Records the current version and build for tracking purposes. ``` -------------------------------- ### Dispatcher Provider Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt Methods for getting and setting the current dispatcher provider. ```APIDOC ## Dispatcher Provider ### Description Manages the current dispatcher provider for MAUI applications. ### Method `DispatcherProvider.Current.get` ### Endpoint N/A (Property Getter) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp var dispatcherProvider = Microsoft.Maui.Dispatching.DispatcherProvider.Current; ``` ### Response #### Success Response (200) `Microsoft.Maui.Dispatching.IDispatcherProvider` - The current dispatcher provider. #### Response Example ```json { "provider": "..." } ``` ``` ```APIDOC ## Dispatcher Provider ### Description Manages the current dispatcher provider for MAUI applications. ### Method `DispatcherProvider.SetCurrent(Microsoft.Maui.Dispatching.IDispatcherProvider provider)` ### Endpoint N/A (Static Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool success = Microsoft.Maui.Dispatching.DispatcherProvider.SetCurrent(myCustomProvider); ``` ### Response #### Success Response (200) `bool` - `true` if the provider was set successfully, `false` otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Reference .NET MAUI Packages in .csproj Source: https://github.com/dotnet/maui/wiki/Nightly-Builds Example of how to reference .NET MAUI control packages within a project's .csproj file. It demonstrates using a version variable for flexibility. ```xml ``` -------------------------------- ### Microsoft.Maui.IDatePicker.Format.get Source: https://github.com/dotnet/maui/blob/main/src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt Gets the format string for the DatePicker. This string determines how the date is displayed. ```APIDOC ## GET Microsoft.Maui.IDatePicker.Format.get ### Description Gets the format string for the DatePicker. ### Method GET ### Endpoint Microsoft.Maui.IDatePicker.Format.get ### Parameters None ### Request Body None ### Response #### Success Response (200) - **string** - The date format string. #### Response Example ```json { "format": "yyyy-MM-dd" } ``` ``` -------------------------------- ### Query and Wait for Elements Source: https://github.com/dotnet/maui/wiki/UITests These methods are used for querying UI elements within a web view or waiting for elements to appear or disappear. Querying defaults to visible elements. QueryUntilPresent and QueryUntilNotPresent allow for retries with specified delays. ```csharp App.QueryUntilPresent(() => App.WaitForElement("success")); ``` -------------------------------- ### Configure Windows App SDK in .csproj Source: https://github.com/dotnet/maui/wiki/Migrating-from-Preview-10-to-11 This snippet shows how to add the Windows App SDK and Microsoft.Graphics.Win2D as package references in the .csproj file. It's conditioned to apply only to Windows target frameworks. ```xml ```