-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add path-specific GitHub Copilot instructions for .NET MAUI Templates #32112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
I've integrated all changes from PR #32148 and improved the template. The changes include: From PR #32148:
Improvements made:
All changes verified in commit 032560e Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| #endif | ||
| .ConfigureMauiHandlers(handlers => | ||
| { | ||
| #if WINDOWS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot for templates can you please make sure to consult template semantics?
For example, these if/defs need to be included into the template code so they need to be surrounded by
//-:cnd:noEmit
#if windows
#endif
//+:cnd:noEmit
Can you please add a copilot instruction that's specific to the templates area location that will ensure you use all the proper rules in the future for updating templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the template semantics in MauiProgram.cs by adding //-:cnd:noEmit and //+:cnd:noEmit markers around the #if WINDOWS directive (lines 24-39).
Also added a comprehensive "Working with Templates" section to .github/copilot-instructions.md that documents:
- When to use
//-:cnd:noEmitmarkers (platform-specific directives like#if WINDOWS,#if DEBUG) - When NOT to use them (template parameters like
#if (IncludeSampleContent)) - Template naming conventions
- Files to exclude from template changes
- Template testing guidelines
- Quick reference table
Changes verified in commit b1e5115 (will be the new commit after this push).
…cument template conventions Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
.github/copilot-instructions.md
Outdated
|
|
||
| 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! | ||
|
|
||
| ## Working with Templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you move this to a specifics sintructions file that uses YAML syntax for only applying to the src/Templates folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved template instructions to .github/copilot-instructions/templates.yml with YAML syntax that applies only to src/Templates/** files. The file uses the applicability.paths configuration to ensure instructions are shown only when working in the Templates directory.
Changes in commit 8955000 (will be the new commit after this push).
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow the guidance here please for this file
https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions-2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed path-specific custom instructions format following GitHub documentation. Changes:
- Renamed from
templates.ymltotemplates.md - Added YAML frontmatter with
applies_tofield - Format now matches GitHub's documented structure
The file now uses the correct format:
---
applies_to:
- src/Templates/**
---Commit 25df86b (will be new commit after push).
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot remove all changes to this PR except for the markdown update to copilot instructions files |
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Reverted all template changes. The PR now contains only the markdown copilot instructions file ( All changes to
Commit 4655b34 (will be new commit after push). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive documentation for working with .NET MAUI template files in the form of a new Copilot instruction guide. The document explains template-specific syntax requirements, conditional compilation directives, naming conventions, and testing workflows.
Key changes:
- Documents the distinction between build-time platform directives (requiring
//-:cnd:noEmitmarkers) and template-time parameter directives (no markers needed) - Provides clear examples of proper directive usage patterns
- Establishes guidelines for template file exclusions and testing procedures
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
/rebase |
|
Here's the text extracted from the image formatted for a GitHub issue: 1. Clarify the "applies_to" Front Matter
---
applies_to:
- src/Templates/**
---
<!-- Applies only to .NET MAUI template sources. Used by GitHub Copilot and policy checkers. -->This ensures future readers or tools don't remove it thinking it's boilerplate. 2. Improve Section Hierarchy and FlowThe current sections mix conceptual, procedural, and reference information. Suggestion: Restructure slightly for readability and AI chunking: # Working with .NET MAUI Templates
## 1. Overview
## 2. Conditional Compilation
- Build-time (Platform-specific)
- Template-time (Template parameters)
## 3. Naming and Placeholders
## 4. Files to Avoid Editing
## 5. Testing and Verification
## 6. Quick Reference TableThis linear progression (concept → naming → exclusions → testing → summary) makes it easier for both Copilot and contributors to infer intent and context when suggesting completions. |
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Implemented all suggested improvements: 1. Clarified front-matter intent:
2. Improved section hierarchy and flow:
This structure makes it easier for both Copilot and contributors to understand the context and find relevant information. Commit f5a6893 (will be new commit after push). |
Summary
This PR adds path-specific custom instructions for GitHub Copilot to help maintain proper template semantics when working with .NET MAUI Templates in the
src/Templates/directory.Latest Changes:
Changes Made
Created
.github/copilot-instructions/templates.mdwith:applies_tofield to targetsrc/Templates/**paths//-:cnd:noEmitmarkersMauiApp._1transformations)Format
The file follows GitHub's official documentation format for path-specific custom instructions:
This ensures GitHub Copilot applies these template-specific instructions only when working in the
src/Templates/directory.Benefits
Testing
Fixes #32111
Original prompt
Fixes #32111
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.