Skip to content

copilot instructions #13046

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
merged 1 commit into from
Mar 24, 2025
Merged

Conversation

Tanya-Solyanik
Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik commented Feb 28, 2025

Developing these instructions will be an iterative process and this is only the first iteration.
There is more we can add later.

https://github.blog/changelog/2025-01-21-custom-repository-instructions-are-now-available-for-copilot-on-github-com-public-preview/

Microsoft Reviewers: Open in CodeFlow

@JeremyKuhne
Copy link
Member

I have no issues with this, letting @KlausLoeffelmann add his additional comments.

@merriemcgaw
Copy link
Member

@Tanya-Solyanik looks like @KlausLoeffelmann is happy with this. Are you ready to merge?

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.67947%. Comparing base (4dc2b59) to head (bdcf4eb).
Report is 30 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #13046          +/-   ##
====================================================
+ Coverage   61.36344%   95.67947%   +34.31603%     
====================================================
  Files           1547         529        -1018     
  Lines         158482       62122       -96360     
  Branches       14752        1309       -13443     
====================================================
- Hits           97250       59438       -37812     
+ Misses         60529        2381       -58148     
+ Partials         703         303         -400     
Flag Coverage Δ
Debug 98.01485% <ø> (+29.75188%) ⬆️
integration ?
production ?
test 98.01485% <ø> (∅)
unit ?

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.


## General

* In the main branch, write code that runs on .NET 10.0, but keep in mind that we have a couple of.NET Framework and multi-targeted code files.
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann Mar 14, 2025

Choose a reason for hiding this comment

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

I am not sure, what you want to achieve with that and on what level. FWIW, if it's targeted to Review instructions, I don't think that those are getting picked up from here.

As for code generation, I think the instruction is not precise enough. You could hint at a certain C# versions, or suggest to use something concrete over something concrete. But I do not think that this comment will change anything in terms of code generation.

Copy link
Contributor Author

@Tanya-Solyanik Tanya-Solyanik Mar 14, 2025

Choose a reason for hiding this comment

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

This is copied from the "lightning talk" presentation, yes this is targeted to the review instructions. This file is consumed by the GH per docs. I want GH Copilot to not suggest getting rid of Range


* In the main branch, write code that runs on .NET 10.0, but keep in mind that we have a couple of.NET Framework and multi-targeted code files.
* Make only high-confidence suggestions when reviewing code changes.
* Do not edit files in `eng/common/`.
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure, if it makes sense to write instructions to prevent vague "in case of" things.

I think makes only sense to prevent an LLM to modify something, when a companion instruction would directly open the possibility that that could happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is targeted for GH code reviews, this is copied from other team's instructions and is a reminder that we don't own files in eng/common

Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

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

I am not connived about the usefulness of many of those.
But the 'Do not modify the Designer code' would be a showstopper for me, so, I would like to veto that, if I may?!

* In the main branch, write code that runs on .NET 10.0, but keep in mind that we have a couple of.NET Framework and multi-targeted code files.
* Make only high-confidence suggestions when reviewing code changes.
* Do not edit files in `eng/common/`.
* Do not edit designer-generated files, i.e. *.Designer.cs and *.Designer.vb files.
Copy link
Member

Choose a reason for hiding this comment

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

And this is something, which I would even block. Because I often ask Copilot to design a Form for me. How should it do that, when it's not allow to edit the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when you open that form in the designer your edits would be lost, and designer generates code that does not follow our naming standard.

Copy link
Member

Choose a reason for hiding this comment

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

This is just for GH Code Review suggestions, right? In that case, I don't see why this would block your scenario @KlausLoeffelmann. Locally on your machine you can certainly ask Copilot edits to help you design a form (I often do as well) but then if making a PR, it would just ignore the code in InitializeComponent() which we would ignore when reviewing as a human anyway since we know it's generated, will be regenerated the next time the form is loaded, and doesn't meet our coding guidance.

## Nullable Reference Types

* Declare variables non-nullable, and check for `null` at entry points.
* Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.
Copy link
Member

Choose a reason for hiding this comment

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

Can you give me a sample, what you mean by this?
And also, for public APIs, wouldn't that be wrong? I mean we always have to check for null and then throw null reference exceptions. So, I am not sure, what you had in mind with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point about public arguments, my intention was to fix things like this -

@@ -102,7 +102,7 @@ internal bool SingleVerticalBorderAdded
### Namespace Usings

1. Namespace `using`s should be specified at the top of the file, before `namespace` declarations, and should be sorted alphabetically, with the exception of `System.*` namespaces, which are to be placed on top of all others.
Copy link
Member

Choose a reason for hiding this comment

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

I would rather add a file header here as a sample, and then simply state, very briefly how to apply that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not my intention to edit this file.

Developing these instructions will be an iterative process and this is only the first iteration. There is probably more we can add later.
https://github.blog/changelog/2025-01-21-custom-repository-instructions-are-now-available-for-copilot-on-github-com-public-preview/
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

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

Let's try this now.
I have a few additional ideas, but they can wait until you're back!

@Tanya-Solyanik Tanya-Solyanik merged commit 5aa291a into dotnet:main Mar 24, 2025
8 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0 Preview4 milestone Mar 24, 2025
@RussKie
Copy link
Contributor

RussKie commented Mar 24, 2025

FWIW, I've been using the following prompt:

# Instructions for GitHub and VisualStudio Copilot
### https://github.blog/changelog/2025-01-21-custom-repository-instructions-are-now-available-for-copilot-on-github-com-public-preview/


## General

* Make only high confidence suggestions when reviewing code changes.
* Always use the latest version C#, currently C# 13 features.
* Files must have CRLF line endings.

## Formatting

* Apply code-formatting style defined in `.editorconfig`.
* Prefer file-scoped namespace declarations and single-line using directives.
* Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.).  
* Ensure that the final return statement of a method is on its own line.
* Use pattern matching and switch expressions wherever possible.
* Use `nameof` instead of string literals when referring to member names.

### **Variable Declarations:**  

*  Never use `var` for primitive types. Use `var` only when the type is obvious from context. When in doubt, opt for an explicit type declaration.

### Nullable Reference Types

* Declare variables non-nullable, and check for `null` at entry points.
* Always use `is null` or `is not null` instead of `== null` or `!= null`.
* Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.


### Testing

* We use MSTest SDK
* Do not emit "Act", "Arrange" or "Assert" comments.
* Use NSubstitute for mocking.
* Use "snake_case" for test method names but keep the original method under test intact.
  For example: when adding a test for method "MethondToTest" instead of "MethondToTest_ShouldReturnSummarisedIssues" use "MethondToTest_should_return_summarised_issues".

@Tanya-Solyanik Tanya-Solyanik deleted the copilot-instructions branch April 4, 2025 22:42
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants