|
| 1 | +--- |
| 2 | +applyTo: '**' |
| 3 | +--- |
| 4 | + |
| 5 | +# GitHub Copilot Development Environment Instructions |
| 6 | + |
| 7 | +This document provides specific guidance for GitHub Copilot when working on the .NET MAUI Samples repository. It serves as context for understanding the project structure, development workflow, and best practices. |
| 8 | + |
| 9 | +## Repository Overview |
| 10 | + |
| 11 | +This repository contains **sample applications and demonstrations** for **.NET MAUI** (Multi-platform App UI), a cross-platform framework for creating mobile and desktop applications with C# and XAML. The samples showcase various features, controls, and capabilities of the .NET MAUI framework across Android, iOS, iPadOS, macOS, and Windows platforms. |
| 12 | + |
| 13 | +### Key Technologies |
| 14 | +- **.NET SDK** - Various versions depending on the sample: |
| 15 | + - **8.0 folder**: Samples targeting .NET 8 |
| 16 | + - **9.0 folder**: Samples targeting .NET 9 |
| 17 | + - **10.0 folder**: Samples targeting .NET 10 |
| 18 | + - etc. |
| 19 | +- **C#** and **XAML** for application development |
| 20 | +- **MSBuild** for building individual samples |
| 21 | +- **Various testing frameworks** including NUnit and Appium for UI testing samples |
| 22 | + |
| 23 | +## Development Environment Setup |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +Before working with .NET MAUI samples, ensure your development environment is properly configured according to the official documentation: |
| 28 | + |
| 29 | +1. **Follow the official .NET MAUI installation guide:** |
| 30 | + - Visit [Install .NET MAUI](https://docs.microsoft.com/dotnet/maui/get-started/installation) for comprehensive setup instructions |
| 31 | + - Install the required .NET SDK version (8.0, 9.0, or 10.0 depending on the sample) |
| 32 | + |
| 33 | +2. **Verify installation:** |
| 34 | + ```powershell |
| 35 | + dotnet --version |
| 36 | + dotnet workload list |
| 37 | + ``` |
| 38 | + |
| 39 | +### Initial Repository Setup |
| 40 | + |
| 41 | +1. **Clone and navigate to repository:** |
| 42 | + ```powershell |
| 43 | + git clone https://github.com/dotnet/maui-samples.git |
| 44 | + cd maui-samples |
| 45 | + ``` |
| 46 | + |
| 47 | +2. **Choose and navigate to the appropriate sample:** |
| 48 | + ```powershell |
| 49 | + # For .NET 10 samples |
| 50 | + cd 10.0/UserInterface/ControlGallery |
| 51 | + |
| 52 | + # For .NET 9 samples |
| 53 | + cd 9.0/Apps/Calculator |
| 54 | + |
| 55 | + # For .NET 8 samples |
| 56 | + cd 8.0/Apps/WeatherTwentyOne |
| 57 | + ``` |
| 58 | + |
| 59 | +3. **Build and run the sample:** |
| 60 | + ```powershell |
| 61 | + dotnet build |
| 62 | + dotnet run |
| 63 | + ``` |
| 64 | + |
| 65 | +## Project Structure |
| 66 | + |
| 67 | +### Important Directories |
| 68 | +- `8.0/` - Samples targeting .NET 8 |
| 69 | +- `9.0/` - Samples targeting .NET 9 |
| 70 | +- `10.0/` - Samples targeting .NET 10 |
| 71 | +- `eng/` - Build engineering and tooling |
| 72 | +- `.github/` - GitHub workflows and configuration |
| 73 | +- `Images/` - Shared images used across samples |
| 74 | +- `Upgrading/` - Migration examples from Xamarin.Forms to .NET MAUI |
| 75 | + |
| 76 | +### Platform-Specific Code Organization |
| 77 | +- **Android** specific code is inside folders labeled `Android` |
| 78 | +- **iOS** specific code is inside folders labeled `iOS` |
| 79 | +- **MacCatalyst** specific code is inside folders named `MacCatalyst` |
| 80 | +- **Windows** specific code is inside folders named `Windows` |
| 81 | + |
| 82 | +### Platform-Specific File Extensions |
| 83 | +- Files with `.windows.cs` will only compile for the Windows TFM |
| 84 | +- Files with `.android.cs` will only compile for the Android TFM |
| 85 | +- Files with `.ios.cs` will only compile for the iOS and MacCatalyst TFM |
| 86 | +- Files with `MacCatalyst.cs` will only compile for the MacCatalyst TFM |
| 87 | + |
| 88 | +### Sample Categories |
| 89 | +``` |
| 90 | +├── Apps/ - Complete sample applications |
| 91 | +│ ├── Calculator/ |
| 92 | +│ ├── WeatherTwentyOne/ |
| 93 | +│ ├── PointOfSale/ |
| 94 | +│ ├── WhatToEat/ |
| 95 | +│ └── ... |
| 96 | +├── UserInterface/ - UI controls and layout demos |
| 97 | +│ ├── ControlGallery/ |
| 98 | +│ ├── Views/ |
| 99 | +│ ├── Layouts/ |
| 100 | +│ └── ... |
| 101 | +├── Navigation/ - Navigation pattern samples |
| 102 | +├── Data/ - Data access and storage samples |
| 103 | +├── WebServices/ - REST API and web service samples |
| 104 | +├── UITesting/ - UI testing with Appium samples |
| 105 | +├── Fundamentals/ - Core concepts like data binding, MVVM |
| 106 | +├── PlatformIntegration/ - Platform-specific features |
| 107 | +├── XAML/ - XAML markup and styling samples |
| 108 | +├── SkiaSharp/ - SkiaSharp graphics samples |
| 109 | +├── Tutorials/ - Step-by-step learning samples |
| 110 | +├── Packaging/ - NuGet packaging and MSBuild samples |
| 111 | +├── Sensors/ - Device sensor integration samples |
| 112 | +└── Animations/ - Animation and visual effects samples |
| 113 | +``` |
| 114 | + |
| 115 | +## Development Workflow |
| 116 | + |
| 117 | +### Creating New Samples |
| 118 | + |
| 119 | +When creating new .NET MAUI samples, use the `dotnet new maui` template: |
| 120 | + |
| 121 | +```powershell |
| 122 | +# Create a new .NET MAUI sample |
| 123 | +dotnet new maui -n SampleName |
| 124 | +
|
| 125 | +# Navigate to the sample directory |
| 126 | +cd SampleName |
| 127 | +``` |
| 128 | + |
| 129 | +### Building Individual Samples |
| 130 | + |
| 131 | +Each sample is self-contained and can be built independently: |
| 132 | + |
| 133 | +```powershell |
| 134 | +# Navigate to a specific sample |
| 135 | +cd 10.0/Apps/Calculator |
| 136 | +
|
| 137 | +# Build the sample |
| 138 | +dotnet build |
| 139 | +
|
| 140 | +# Run the sample (if supported on current platform) |
| 141 | +dotnet run |
| 142 | +``` |
| 143 | + |
| 144 | +### Sample Structure |
| 145 | + |
| 146 | +Most samples follow this structure: |
| 147 | +``` |
| 148 | +SampleName/ |
| 149 | +├── SampleName.sln - Solution file |
| 150 | +├── SampleName/ - Main project folder |
| 151 | +├── Screenshots/ - Sample screenshots (PNG format) |
| 152 | +└── README.md - Sample documentation |
| 153 | +``` |
| 154 | + |
| 155 | +## Sample Requirements |
| 156 | + |
| 157 | +### Required Files and Structure |
| 158 | + |
| 159 | +Every sample must include: |
| 160 | + |
| 161 | +1. **README.md** - Documentation file with YAML front matter header |
| 162 | +2. **Screenshots folder** - Empty folder for future screenshots |
| 163 | +3. **Project files** - Standard .NET MAUI project structure |
| 164 | +4. **Solution file** - `.sln` file for the sample |
| 165 | + |
| 166 | +### README.md Format |
| 167 | + |
| 168 | +Each sample's README.md must follow this format: |
| 169 | + |
| 170 | +```markdown |
| 171 | +--- |
| 172 | +name: .NET MAUI - Sample Name |
| 173 | +description: Brief description of what the sample demonstrates. |
| 174 | +page_type: sample |
| 175 | +languages: |
| 176 | +- csharp |
| 177 | +- xaml |
| 178 | +products: |
| 179 | +- dotnet-maui |
| 180 | +urlFragment: category-samplename |
| 181 | +--- |
| 182 | + |
| 183 | +# Sample Name |
| 184 | + |
| 185 | +Detailed description of the sample, its purpose, and key features demonstrated. |
| 186 | + |
| 187 | +``` |
| 188 | + |
| 189 | +**Key elements:** |
| 190 | +- **YAML front matter** with metadata (name, description, page_type, languages, products, urlFragment) |
| 191 | +- **Clear sample name** in the `name` field prefixed with ".NET MAUI - " |
| 192 | +- **Concise description** explaining what the sample demonstrates |
| 193 | +- **URL fragment** following the pattern: `category-samplename` (lowercase, hyphenated) |
| 194 | +- **Detailed content** explaining the sample's purpose and features |
| 195 | + |
| 196 | +### Screenshots Requirements |
| 197 | + |
| 198 | +- Create an empty `Screenshots/` folder in each sample directory |
| 199 | +- Screenshots will be added later by maintainers |
| 200 | + |
| 201 | +### Testing and Debugging |
| 202 | + |
| 203 | +#### UI Testing Guidelines |
| 204 | + |
| 205 | +Some samples include UI testing with Appium and NUnit. When working with UI testing samples: |
| 206 | + |
| 207 | +1. **Navigate to the UI testing sample:** |
| 208 | + ```powershell |
| 209 | + cd 10.0/UITesting/BasicAppiumNunitSample |
| 210 | + ``` |
| 211 | + |
| 212 | +2. **Build the test projects:** |
| 213 | + ```powershell |
| 214 | + dotnet build UITests.Shared/UITests.Shared.csproj |
| 215 | + ``` |
| 216 | + |
| 217 | +3. **Run platform-specific tests:** |
| 218 | + ```powershell |
| 219 | + # For Android |
| 220 | + dotnet build UITests.Android/UITests.Android.csproj |
| 221 | + # For iOS (on macOS) |
| 222 | + dotnet build UITests.iOS/UITests.iOS.csproj |
| 223 | + ``` |
| 224 | + |
| 225 | +## Additional Resources |
| 226 | + |
| 227 | +- [.NET MAUI Documentation](https://docs.microsoft.com/dotnet/maui) |
| 228 | +- [.NET MAUI GitHub Repository](https://github.com/dotnet/maui) |
| 229 | +- [Samples Browser](https://docs.microsoft.com/samples/browse/?expanded=dotnet&products=dotnet-maui) |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +**Note for Future Updates:** This document should be expanded as new development patterns, tools, or workflows are discovered. Add sections for specific scenarios, debugging techniques, or tooling as they become relevant to the development process. |
0 commit comments