Skip to content

Commit 8d3f904

Browse files
authored
Update CONTRIBUTING.md (#12714)
* Update CONTRIBUTING.md * Tweak contributing. * Add link to contributing guide. * Added example "good" PR description.
1 parent df0342f commit 8d3f904

File tree

2 files changed

+58
-34
lines changed

2 files changed

+58
-34
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!--- See CONTRIBUTING.md for general guidelines on contributions -->
2+
13
## What does the pull request do?
24
<!--- Give a bit of background on the PR here, together with links to with related issues etc. -->
35

Diff for: CONTRIBUTING.md

+56-34
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,79 @@
11
# Contributing to Avalonia
22

3-
## Before You Start
3+
PRs are always welcomed from everyone. Following this guide will help us get your PR reviewed and merged as quickly as possible.
44

5-
Drop into our [telegram group](https://t.me/Avalonia) or [gitter chat room](https://gitter.im/AvaloniaUI/Avalonia) and let us know what you're thinking of doing. We might be able to give you guidance or let you know if someone else is already working on the feature.
5+
For this guide we're going to split PRs into two types: bug fixes and features; the requirements for each are slightly different.
66

7-
## Style
7+
## Bug Fixes
88

9-
The codebase uses [.net core](https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/coding-style.md) coding style.
9+
A bug fix will ideally be accompanied by tests. There are a few types of tests:
1010

11-
Try to keep lines of code around 100 characters in length or less, though this is not a hard limit.
12-
If you're a few characters over then don't worry too much.
11+
- Unit tests are for issues that aren't related to platform features. These tests are located in the `tests` directly, categorised by the assembly which they're testing.
12+
- Integration tests are for issues that are related to platform features (for example fixing a bug with Window resizing). These tests are located in the `tests/Avalonia.IntegrationTests.Appium` directory. Integration tests should be run on Windows and macOS. See the readme in that directory for more information
13+
- Render tests are for issues with rendering. These tests are located in `tests/Avalonia.RenderTests` with separate project files for Skia and Direct2D. The Direct2D backend is currently mostly unmaintained so render tests that just run on Skia are acceptable
1314

14-
**DO NOT USE #REGIONS** full stop.
15+
It's not always feasible to accompany a bug fix with a test, but doing so will speed up the review process.
1516

16-
## Pull requests
17+
The commits in a bug fix PR **should follow this pattern**:
1718

18-
A single pull request should be submitted for each change. If you're making more than one change,
19-
please submit separate pull requests for each change for easy review. Rebase your changes to make
20-
sense, so a history that looks like:
19+
- A commit with a failing unit test; followed by
20+
- A commit that fixes the issues
2121

22-
* Add class A
23-
* Feature A didn't set Foo when Bar was set
24-
* Fix spacing
25-
* Add class B
26-
* Sort using statements
22+
In this way the reviewer can check out the commit with the failing test and confirm the problem. One this is confirmed, they can confirm the fix.
2723

28-
Should be rebased to read:
24+
## Features
2925

30-
* Add class A
31-
* Add class B
26+
**Features should be discussed with the core team before opening a PR.** Please open an issue to discuss the feature before starting work, to ensure that the core team are onboard.
3227

33-
Again, this makes review much easier.
28+
Features should always include unit tests or integration tests where possible.
3429

35-
Please try not to submit pull requests that don't add new features (e.g. moving stuff around)
36-
unless you see something that is obviously wrong or that could be written in a more terse or
37-
idiomatic style. It takes time to review each pull request - time that I'd prefer to spend writing
38-
new features!
30+
> One exception to this is features related to DevTools which has no tests currently
3931
40-
Prefer terseness to verbosity but don't try to be too clever.
32+
Features that introduce new controls should consider the following:
4133

42-
## Tests
34+
- Ideally the control should be exposed to the operating system's automation/accessibility APIs by writing an `AutomationPeer`
35+
- If the control introduces any functionality which is difficult to unit test, an integration test should be written
4336

44-
There are two types of tests currently in the codebase; unit tests and render tests.
37+
## General Guidance
4538

46-
Unit tests should be contained in a class name that mirrors the class being tested with the suffix
47-
-Tests, e.g.
39+
## PR description
4840

49-
Avalonia.Controls.UnitTests.Presenters.TextPresenterTests
41+
- The PR template contains sections to fill in. These are discretionary and are intended to provide guidance rather than being prescritive: feel free to delete sections that do not apply, or add additional sections
42+
- **Please** provide a good description of the PR. Not doing so **will** delay review of the PR at a minimum, or may cause it to be closed. If English isn't your first language, consider using ChatGPT or another tool to write the description. If you're looking for a good example of a PR description see https://github.com/AvaloniaUI/Avalonia/pull/12765 for example.
43+
- Link any fixed issues with a `Fixes #1234` comment
5044

51-
Where Avalonia.Controls.UnitTests is the name of the project.
45+
## Breaking changes
5246

53-
Unit test methods should be named in a sentence style, separated by underscores, that describes in
54-
English what the test is testing, e.g.
47+
- During a major release cycle, source or binary breaking changes may not be introduced to the codebase: this is checked by an automated tool and will cause CI to fail
48+
- If something needs addressing in the next major release, you can leave a `TODOXX:` comment, where `XX` is the version number of the next major release, e.g. `TODO12:`
49+
- Carefully consider behavioral breaking changes and point them out in the PR description
50+
51+
### Commits
52+
53+
In addition to the guidance in the `Bug Fixes` section, following these guidelines may help to get your PR reviewed in a timely manner:
54+
55+
- Rebase your changes to remove extraneous commits. Ideally the commit history should tell a clean story of how the PR was implemented (even though the process was probably not clean!)
56+
- Provide meaningful commit comments
57+
- **Do not** change code unrelated to the bug fix/feature
58+
- **Do not** introduce spurious formatting or whitespace changes
59+
60+
While it's tempting to fix style issues you encounter, don't do it:
61+
62+
- It causes the reviewer to get distracted by unrelated changes
63+
- It makes finding the cause of any later issue more difficult (blame/bisect is made more difficult)
64+
- As the code churns, style issues will be resolved anyway
65+
66+
Separate PRs for style issues may be accepted if agreed with the core team in advance.
67+
68+
### Style
69+
70+
- The codebase uses [.net core](https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/coding-style.md) coding style.
71+
- Try to keep lines of code around 120 characters in length or less, though this is not a hard limit. If you're a few characters over then don't worry too much.
72+
- Public methods should have XML documentation
73+
- Prefer terseness to verbosity but don't try to be too clever.
74+
- **DO NOT USE #REGIONS** full stop
75+
76+
Tests do not follow the usual method naming convention. Instead they should be named in a sentence style, separated by underscores, that describes in English what the test is testing, e.g.
5577

5678
```csharp
5779
void Calling_Foo_Should_Increment_Bar()
@@ -66,4 +88,4 @@ Render tests should describe what the produced image is:
6688
## Code of Conduct
6789

6890
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
69-
For more information see the [Contributor Covenant Code of Conduct](https://dotnetfoundation.org/code-of-conduct)
91+
For more information see the [Contributor Covenant Code of Conduct](https://dotnetfoundation.org/code-of-conduct)

0 commit comments

Comments
 (0)