Skip to content

Commit 5740076

Browse files
CopilotPureWeen
andauthored
Extract markdown documentation changes from PR #32064 and merge enhancements from PR #32270 (#32280)
* Initial plan * Extract markdown documentation changes from PR #32064 Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> * Merge UI testing documentation enhancements from PR #32270 Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> * - consolidate instruction based PRs * Fix code block language identifiers and indentation in UITesting-Guide.md Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> * Add references to comprehensive UI testing documentation in copilot-instructions.md Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> * Add frontmatter metadata to UI testing documentation files Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> * Add date field to frontmatter metadata in all markdown files Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
1 parent f827d3c commit 5740076

File tree

7 files changed

+1288
-199
lines changed

7 files changed

+1288
-199
lines changed

.github/copilot-instructions.md

Lines changed: 90 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
description: "Guidance for GitHub Copilot when working on the .NET MAUI repository."
3+
date: 2025-10-30
4+
---
5+
16
# GitHub Copilot Development Environment Instructions
27

38
This document provides specific guidance for GitHub Copilot when working on the .NET MAUI repository. It serves as context for understanding the project structure, development workflow, and best practices.
@@ -7,14 +12,24 @@ This document provides specific guidance for GitHub Copilot when working on the
712
**.NET MAUI** is a cross-platform framework for creating mobile and desktop applications with C# and XAML. This repository contains the core framework code that enables development for Android, iOS, iPadOS, macOS, and Windows from a single shared codebase.
813

914
### Key Technologies
10-
- **.NET SDK** - Version depends on the branch:
11-
- **main branch**: Use the latest stable version of .NET to build
15+
16+
- **.NET SDK** - Version is **ALWAYS** defined in `global.json` at repository root
17+
- **main branch**: Use the latest stable version of .NET to build (currently .NET 10)
1218
- **net10.0 branch**: Use the latest .NET 10 SDK
1319
- **etc.**: Each feature branch correlates to its respective .NET version
1420
- **C#** and **XAML** for application development
1521
- **Cake build system** for compilation and packaging
1622
- **MSBuild** with custom build tasks
17-
- **xUnit** for testing
23+
- **xUnit + NUnit** for testing (xUnit for unit tests, NUnit for UI tests)
24+
25+
**🚨 CRITICAL**: Before any build operation, verify .NET SDK version:
26+
```bash
27+
# Check required version
28+
cat global.json | grep -A 1 '"dotnet"'
29+
30+
# Verify installed version matches
31+
dotnet --version
32+
```
1833

1934
## Development Environment Setup
2035

@@ -31,6 +46,8 @@ For .NET installation on Linux, follow the official Microsoft documentation:
3146

3247
### Initial Repository Setup
3348

49+
**🚀 Mandatory Setup Sequence** - Run these in exact order:
50+
3451
1. **Clone and navigate to repository:**
3552
```bash
3653
git clone https://github.com/dotnet/maui.git
@@ -43,6 +60,15 @@ For .NET installation on Linux, follow the official Microsoft documentation:
4360
dotnet build ./Microsoft.Maui.BuildTasks.slnf
4461
```
4562

63+
**⚠️ FAILURE RECOVERY**: If restore or build fails:
64+
```bash
65+
# Clean and retry
66+
dotnet clean
67+
rm -rf bin/ obj/
68+
dotnet tool restore --force
69+
dotnet build ./Microsoft.Maui.BuildTasks.slnf --verbosity normal
70+
```
71+
4672
## Project Structure
4773

4874
### Important Directories
@@ -68,14 +94,14 @@ For .NET installation on Linux, follow the official Microsoft documentation:
6894

6995
### Sample Projects
7096
```
71-
├── Controls
97+
├── Controls
7298
│ ├── samples
7399
│ │ ├── Maui.Controls.Sample
74100
│ │ ├── Maui.Controls.Sample.Sandbox
75-
├── Essentials
101+
├── Essentials
76102
│ ├── samples
77103
│ │ ├── Essentials.Sample
78-
├── BlazorWebView
104+
├── BlazorWebView
79105
│ ├── samples
80106
│ │ ├── BlazorWinFormsApp
81107
│ │ ├── BlazorWpfApp
@@ -112,50 +138,15 @@ dotnet cake --target=dotnet-pack
112138

113139
#### UI Testing Guidelines
114140

115-
When adding UI tests to validate visual behavior and user interactions, follow this two-part pattern:
116-
117-
**CRITICAL: UITests require code in TWO separate projects that must BOTH be implemented:**
118-
119-
1. **HostApp UI Test Page** (`src/Controls/tests/TestCases.HostApp/Issues/`)
120-
- Create the actual UI page that demonstrates the feature or reproduces the issue
121-
- Use XAML with proper `AutomationId` attributes on interactive controls for test automation
122-
- Follow naming convention: `IssueXXXXX.xaml` and `IssueXXXXX.xaml.cs`
123-
- Ensure the UI provides clear visual feedback for the behavior being tested
124-
125-
2. **NUnit Test Implementation** (`src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/`)
126-
- Create corresponding Appium-based NUnit tests that inherit from `_IssuesUITest`
127-
- Use the `AutomationId` values to locate and interact with UI elements
128-
- Follow naming convention: `IssueXXXXX.cs` (matches the HostApp file)
129-
- Include appropriate `[Category(UITestCategories.XYZ)]` attributes
130-
- Test should validate expected behavior through UI interactions and assertions
131-
132-
**UI Test Pattern Example:**
133-
```csharp
134-
// In TestCases.Shared.Tests/Tests/Issues/IssueXXXXX.cs
135-
public class IssueXXXXX : _IssuesUITest
136-
{
137-
public override string Issue => "Description of the issue being tested";
138-
139-
public IssueXXXXX(TestDevice device) : base(device) { }
140-
141-
[Test]
142-
[Category(UITestCategories.Layout)] // or appropriate category
143-
public void TestMethodName()
144-
{
145-
App.WaitForElement("AutomationId");
146-
App.Tap("AutomationId");
147-
// Add assertions to verify expected behavior
148-
}
149-
}
150-
```
151-
152-
**Before committing UI tests:**
153-
- Compile both the HostApp project and TestCases.Shared.Tests project to ensure no build errors
154-
- Verify AutomationId references match between XAML and test code
155-
- Ensure tests follow the established naming and inheritance patterns
156-
- There should be only one `[Category]` attribute per test, pick the most appropriate one
141+
**Key reminders:**
142+
- UI tests require code in TWO projects: `TestCases.HostApp/Issues/` (UI page) and `TestCases.Shared.Tests/Tests/Issues/` (test implementation)
143+
- Avoid platform-specific directives (`#if ANDROID`, `#if IOS`, etc.) unless absolutely necessary - tests should run on all applicable platforms by default
144+
- When a new UI test category is added to `UITestCategories.cs`, also update `ui-tests.yml` to include the new category
157145

158-
IMPORTANT NOTE: When a new UI test category is added to `UITestCategories.cs`, we need to also update the `ui-tests.yml` to include this new category. Make sure to detect this in your reviews.
146+
**For comprehensive UI testing guidance**, see:
147+
- [UI Testing Guide](../docs/UITesting-Guide.md) - Complete guide with prerequisites, examples, and best practices
148+
- [UI Testing Architecture](../docs/design/UITesting-Architecture.md) - CI/CD integration and architecture details
149+
- [Path-specific UI Test Instructions](instructions/uitests.instructions.md) - Detailed instructions for test files
159150

160151
### Code Formatting
161152

@@ -266,14 +257,60 @@ All PRs are required to have this at the top of the description:
266257

267258
Always put that at the top, without the block quotes. Without it, the users will NOT be able to try the PR and your work will have been in vain!
268259

260+
## Troubleshooting
261+
262+
### Common Build Issues
263+
264+
**Issue: "Build tasks not found"**
265+
```bash
266+
# Solution: Rebuild build tasks
267+
dotnet clean ./Microsoft.Maui.BuildTasks.slnf
268+
dotnet build ./Microsoft.Maui.BuildTasks.slnf
269+
```
270+
271+
**Issue: "Dependency version conflicts"**
272+
```bash
273+
# Solution: Full clean and restore
274+
dotnet clean Microsoft.Maui.sln
275+
rm -rf bin/ obj/
276+
dotnet restore Microsoft.Maui.sln --force
277+
```
278+
279+
**Issue: "Android SDK not found"**
280+
```bash
281+
# Solution: Check and install Android components
282+
android # Opens Android SDK Manager
283+
# Or set environment variable: export ANDROID_HOME=/path/to/android-sdk
284+
```
285+
286+
**Issue: "PublicAPI analyzer failures"**
287+
```bash
288+
# Solution: Use format analyzers first
289+
dotnet format analyzers Microsoft.Maui.sln
290+
# If still failing, check build output for required API entries
291+
```
292+
293+
### Platform-Specific Troubleshooting
294+
295+
**iOS/Mac Build Issues:**
296+
- Verify Xcode command line tools: `xcode-select --install`
297+
- Check Xcode version compatibility with .NET MAUI version
298+
- Ensure provisioning profiles are current (for device testing)
299+
300+
**Android Build Issues:**
301+
- Verify OpenJDK 17 installation: `java -version`
302+
- Check ANDROID_HOME environment variable
303+
- Update Android SDK components via Android SDK Manager
304+
305+
**Windows Build Issues:**
306+
- Ensure Windows SDK is installed
307+
- Verify Visual Studio workloads include .NET MAUI development
308+
- Check for missing NuGet packages: `dotnet restore --force`
309+
269310
## Additional Resources
270311

271312
- [Development Guide](.github/DEVELOPMENT.md)
272313
- [Development Tips](docs/DevelopmentTips.md)
273314
- [Contributing Guidelines](.github/CONTRIBUTING.md)
274315
- [Testing Wiki](https://github.com/dotnet/maui/wiki/Testing)
275316
- [.NET MAUI Documentation](https://docs.microsoft.com/dotnet/maui)
276-
277-
---
278-
279-
**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.

.github/copilot-instructions/templates.md renamed to .github/instructions/templates.instructions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
2-
applies_to:
3-
- src/Templates/**
2+
applyTo: "src/Templates/**"
3+
date: 2025-10-30
44
---
5-
<!-- This front-matter configures path-specific Copilot instructions for template files -->
65

76
# Working with .NET MAUI Templates
87

0 commit comments

Comments
 (0)