Skip to content

Update copilot instructions #13586

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

Merged

Conversation

KlausLoeffelmann
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann commented Jun 11, 2025

This PR is adding a way more detailed instruction set according to our .editorConfig enforced coding-standards, and it helps with refactorings or code generation from Copilot to minimize manual work.

It also adds a set of rules for GDI/GDI+ based renderer instructions.

The latter does not get automatically involved. If you have a code file which you for example would like to review according to our standards, which are reflected by those instructions, prompt as an example something like this:

"Could you review the code file #MyNewGridViewRenderer.cs according to the GDI+ instructions in #GDIPlus-copilot-instructions.md"

Important: These instructions do NOT have any influence on how Copilot is reviewing PRs!

Note: If you wish the edit or expand on those instructions, please do not just read the instructions and interpret them as you would. If you think you need to improve them, please try your changes first with concrete example to make sure, what you want to change is actual an improvement.

I have tested and iterated on these instructions intensively.
They are a considerable improvement compared to what we had before.

Please try them and use them and consider adding additional ones for additional topics.

Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

@Copilot Copilot AI left a 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 refactors the solution to externalize Copilot instruction files into dedicated solution folders and adds detailed GDI+ guidance for WinForms renderers.

  • Moves .github/copilot-instructions.md into a new “Copilot” solution folder
  • Introduces a “Rendering” solution folder containing GDIPlus-copilot-instructions.md
  • Adds comprehensive GDI+ best-practices documentation for performance, quality, and resource management

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Winforms.sln Added “Copilot” and “Rendering” solution folders; reorganized SolutionItems and configuration mappings
.github/copilot/GDIPlus-copilot-instructions.md New file with 300+ lines of GDI+ usage guidelines and examples
Comments suppressed due to low confidence (2)

.github/copilot/GDIPlus-copilot-instructions.md:17

  • [nitpick] Consider rephrasing the header to remove the comma—e.g. “### APIs that already provide cached Pens or Brushes”—for improved readability.
### APIs, which already provide cached Pens or Brushes.

Winforms.sln:1207

  • Solution folders don’t require project configuration mappings in the GlobalSection; this entry may be misconfigured or unnecessary and could be removed to avoid build warnings.
{D619FF8C-D99A-48AB-B16B-2F0E819B46D5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.60143%. Comparing base (264f309) to head (2833c9f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #13586          +/-   ##
====================================================
- Coverage   97.40051%   76.60143%   -20.79909%     
====================================================
  Files           1181        3235        +2054     
  Lines         352685      639321      +286636     
  Branches        5368       47314       +41946     
====================================================
+ Hits          343517      489729      +146212     
- Misses          8412      146010      +137598     
- Partials         756        3582        +2826     
Flag Coverage Δ
Debug 76.60143% <ø> (-20.79909%) ⬇️
integration 18.78282% <ø> (?)
production 51.00964% <ø> (?)
test 97.40051% <ø> (ø)
unit 48.41681% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@merriemcgaw merriemcgaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very thorough instructions!

```

Other examples for switch expressions are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that this "others" section doesn't have the markdown indicating csharp code, but most of the other example sections do. Just curious if that's intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant for the LLM, but for the color coding.
It's something which will most likely correct itself in the next iteration. But good catch!


- **Prefer modern collection initializers**: Use `[]` syntax for collections

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's we're back to indicating CSharp code, hence the question above. 😸

- **Insert final newline at end of files**
- **Use 4-space indentation consistently**

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does bold instruct copilot that these are more important instructions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since an LLM spilled this instruction out, it might!

@KlausLoeffelmann KlausLoeffelmann merged commit eb755df into dotnet:main Jun 12, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants