You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PRs are always welcomed from everyone. Following this guide will help us get your PR reviewed and merged as quickly as possible.
4
4
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.
6
6
7
-
## Style
7
+
## Bug Fixes
8
8
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:
10
10
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
13
14
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.
15
16
16
-
## Pull requests
17
+
The commits in a bug fix PR **should follow this pattern**:
17
18
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
21
21
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.
27
23
28
-
Should be rebased to read:
24
+
## Features
29
25
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.
32
27
33
-
Again, this makes review much easier.
28
+
Features should always include unit tests or integration tests where possible.
34
29
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
39
31
40
-
Prefer terseness to verbosity but don't try to be too clever.
32
+
Features that introduce new controls should consider the following:
41
33
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
43
36
44
-
There are two types of tests currently in the codebase; unit tests and render tests.
37
+
## General Guidance
45
38
46
-
Unit tests should be contained in a class name that mirrors the class being tested with the suffix
- 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
50
44
51
-
Where Avalonia.Controls.UnitTests is the name of the project.
45
+
## Breaking changes
52
46
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.
55
77
56
78
```csharp
57
79
voidCalling_Foo_Should_Increment_Bar()
@@ -66,4 +88,4 @@ Render tests should describe what the produced image is:
66
88
## Code of Conduct
67
89
68
90
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