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
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+38-23Lines changed: 38 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ Having that said, if you are a first-timer and you could use some help please re
8
8
9
9
Furthermore, for anyone, we would like you to take into consideration the following guidelines.
10
10
11
+
## Kindness
12
+
11
13
### Make an effort to be nice
12
14
13
15
If you disagree, that's fine. We don't think about everything the same way, be respectful and at some point decide to agree to disagree. If a decision needs to be made, try to involve at least one other person without continuing an endless discussion.
@@ -20,13 +22,13 @@ During a code review try to make a habit out of it to say at least one nice thin
20
22
21
23
Remember English is not everyones native language. Written communication always lacks non-verbal communication. With written communication in a language that is not your native tongue it is even harder to express certain emotions.
22
24
23
-
Always assume that people mean to do right. Try to read a sentence a couple of times over and take things more literal. Try to place yourself in their shoes and see the message beyond the actual words.
25
+
Always assume that people mean to do right. Try to read a sentence a couple of times over and take things more literal. Try to place yourself in their shoes and see the message beyond the actual words.
24
26
25
27
Things might come across different than they were intended, please keep that in mind and always check to see how someone meant it. If you're not sure, pull someone offline in a private channel on Twitter or email and chat about it for a bit. Maybe even jump on a call to collaborate. We're living in the 21st century, all the tools are there, why not use them to get to know each other and be friends?!
26
28
27
29
Besides language, we understand that contributing to open-source mostly happens in your spare time. Remember that priorities might change and we can only spend our time once. This works as a two-way street: don't expect things to be solved instantly, but also please let us know if you do not have the capacity to finish work you have in progress. There is no shame in that. That way it's clear to other people that they can step in and take over.
28
30
29
-
### THANK YOU!
31
+
### THANK YOU
30
32
31
33
Lastly, a big thank you for spending your precious time on our project. We appreciate any effort you make to help us with this project.
32
34
@@ -45,7 +47,7 @@ We will take appropriate actions and measures if necessary.
1. Install .NET MAUI workloads (we recommend using Visual Studio installer)
47
49
48
-
> You will need to complete a Contribution License Agreement before any pull request can be accepted. Complete the CLA at https://cla.dotnetfoundation.org/. This will also be triggered whenever you open a PR and the link should guide you through it.
50
+
> You will need to complete a Contribution License Agreement before any pull request can be accepted. Complete the CLA at <https://cla.dotnetfoundation.org/>. This will also be triggered whenever you open a PR and the link should guide you through it.
49
51
50
52
## Reporting a bug
51
53
@@ -59,10 +61,10 @@ We always request a reproduction sample, and that's not to make your life hard o
59
61
60
62
And most important: **Please, help us to help you ❤️**
61
63
62
-
63
64
## Opening a PR process
64
65
65
66
### TL;DR
67
+
66
68
* Find an issue/feature, make sure that the issue/feature has been `Approved` and is welcomed (also see [New Features](https://github.com/CommunityToolkit/Maui#submitting-a-new-feature))
67
69
* Fork repository
68
70
* Create branch
@@ -73,13 +75,16 @@ And most important: **Please, help us to help you ❤️**
We love your enthusiasm, but small changes and small PRs are easier to digest. We're all doing this in our spare time, it is easier to review a couple of small things and merge that and iterate from there than to have a PR with 100+ files changed that will sit there forever.
81
85
82
86
#### Added features should have tests, a sample and documentation
87
+
83
88
We like quality as much as the next person, so please provide tests.
84
89
85
90
In addition, we would want a new feature or change to be as clear as possible for other developers. Please add a sample to the sample app as part of your PR and also provide a PR to our [documentation repository](https://github.com/MicrosoftDocs/CommunityToolkit).
@@ -88,67 +93,75 @@ In addition, we would want a new feature or change to be as clear as possible fo
88
93
89
94
If you are unsure on where to locate the changes you need to make then please use the following section and flowchart.
In general, this project will have all the basement to develop our Toolkit, including some primitive types, interfaces and base classes, base views, and common code. This will be referenced by other Frameworks/Toolkit based on .NET MAUI that wants to have the same features that us.
96
101
97
-
Here we will have some:
102
+
We ask that all classes in `CommunityToolkit.Maui.Core` are `public`. This allows developers to extend `CommunityToolkit.Maui.Core`. The `[EditorBrowsable(EditorBrowsableState.Never)]` attribute can be added to classes that we don't recommend developers discovering.
98
103
99
-
- BaseViews, could be Views that will be used by other Views, like PaddingButton (that's used by Snackbar) or the MauiPopup (used by Popup) that will be a native control implemented in a way that can work with our handler. This same approach is used here
104
+
Here is an example of classes thatwill
100
105
101
-
- Primitives, which will be base types that can be used by everyone, like our MathOperator. So other frameworks may not have the concept of Behavior or Converter but they can mimic them as helper classes/methods and use our primitives.
106
+
* BaseViews, could be Views that will be used by other Views, like PaddingButton (that's used by Snackbar) or the MauiPopup (used by Popup) that will be a native control implemented in a way that can work with our handler. This same approach is used here
102
107
103
-
- Common Code, this will be all generic code (platform-specific or not) that can be used by other Frameworks/Toolkits
108
+
* Primitives, which will be base types that can be used by everyone, like our MathOperator. So other frameworks may not have the concept of Behavior or Converter but they can mimic them as helper classes/methods and use our primitives.
104
109
105
-
- Layout Managers, were introduced on .NET MAUI and they live on Microsoft.Maui.Core so makes sense to have our managers on Core as well.
110
+
* Common Code, this will be all generic code (platform-specific or not) that can be used by other Frameworks/Toolkits
106
111
107
-
- Handlers, on Core will be the most general Handler with the majority of features.
112
+
* Layout Managers, were introduced on .NET MAUI and they live on Microsoft.Maui.Core so makes sense to have our managers on Core as well.
108
113
109
-
### CommunityToolkit.Maui:
114
+
* Handlers, on Core will be the most general Handler with the majority of features.
115
+
116
+
### CommunityToolkit.Maui
110
117
111
118
This project has a reference to the Core project. Here will live the implementation of our Controls, Views, Behaviors, Animations, etc. In other words, this project will work with the .NET MAUI and will be MVVM friendly. Also, other Toolkits/Frameworks can reference this package if needed.
112
119
113
120
Here we will have some:
114
121
115
-
- View Implementation, with BindableProperties, support to attach effects, behaviors, triggers, and all that jazz.
122
+
* View Implementation, with BindableProperties, support to attach effects, behaviors, triggers, and all that jazz.
116
123
117
-
- Platform Configuration, that is Platform-specific features, that can relate to some control - like the ArrowDirection that is part of Popup and works just on iOS - or the application itself - like the StatusBarColorEffect from XCT.
124
+
* Platform Configuration, that is Platform-specific features, that can relate to some control - like the ArrowDirection that is part of Popup and works just on iOS - or the application itself - like the StatusBarColorEffect from XCT.
118
125
119
-
- Handlers Implementation, We will add to our PropertyMapper and/or CommandMapper any Platform Configuration that some Handler/View may have. We also can implement here some features that we think will not be great to have on Core. Here is a reference for this
126
+
* Handlers Implementation, We will add to our PropertyMapper and/or CommandMapper any Platform Configuration that some Handler/View may have. We also can implement here some features that we think will not be great to have on Core. Here is a reference for this
120
127
121
-
- Layout, will be the implementation of ours custom layouts and will use the Layout Managers on Core
128
+
* Layout, will be the implementation of ours custom layouts and will use the Layout Managers on Core
122
129
123
130
## Contributing Code - Best Practices
124
131
125
132
### Debug Logging
133
+
126
134
* Always use `Trace.WriteLine()` instead of `Debug.WriteLine` for debug logging because `Debug.WriteLine` is removed by the compiler in Release builds
127
135
128
136
### Methods Returning Task and ValueTask
137
+
129
138
* Always include a `CancellationToken` as a parameter to every method returning `Task` or `ValueTask`
130
139
* If the method is public, provide a the default value for the `CancellationToken` (eg `CancellationToken token = default`)
131
140
* If the method is not publc, do not provide a default value for the `CancellationToken`
132
141
* Use `CancellationToken.ThrowIfCancellationRequested()` to verify the `CancellationToken`
133
142
134
143
### Enums
144
+
135
145
* Always use `Unknown` at index 0 for return types that may have a value that is not known
136
146
* Always use `Default` at index 0 for option types that can use the system default option
137
147
* Follow naming guidelines for tense... `SensorSpeed` not `SensorSpeeds`
138
148
* Assign values (0,1,2,3) for all enums
139
149
140
150
### Property Names
151
+
141
152
* Include units only if one of the platforms includes it in their implementation. For instance HeadingMagneticNorth implies degrees on all platforms, but PressureInHectopascals is needed since platforms don't provide a consistent API for this.
142
153
143
154
### Units
155
+
144
156
* Use the standard units and most well accepted units when possible. For instance Hectopascals are used on UWP/Android and iOS uses Kilopascals so we have chosen Hectopascals.
145
157
146
158
### Pattern matching
147
159
148
160
#### Null checking
161
+
149
162
* Prefer using `is` when checking for null instead of `==`.
150
163
151
-
e.g.
164
+
e.g.
152
165
153
166
```csharp
154
167
// null
@@ -180,9 +193,10 @@ if (something is Bucket bucket)
180
193
```
181
194
182
195
### File Scoped Namespaces
196
+
183
197
* Use [file scoped namespaces](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) to help reduce code verbosity.
184
198
185
-
e.g.
199
+
e.g.
186
200
187
201
```csharp
188
202
namespaceCommunityToolkit.Maui.Converters;
@@ -215,13 +229,13 @@ In other words, `NotImplementedException` implies that a feature is still in dev
215
229
216
230
### Bug Fixes
217
231
218
-
If you're looking for something to fix, please browse [open issues](https://github.com/CommunityToolkit/Maui/issues).
232
+
If you're looking for something to fix, please browse [open issues](https://github.com/CommunityToolkit/Maui/issues).
219
233
220
234
Follow the style used by the [.NET Foundation](https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/coding-style.md), with two primary exceptions:
221
235
222
-
- We do not use the `private` keyword as it is the default accessibility level in C#.
223
-
- We will **not** use `_` or `s_` as a prefix for internal or private field names
224
-
- We will use `camelCaseFieldName` for naming internal or private fields in both instance and static implementations
236
+
* We do not use the `private` keyword as it is the default accessibility level in C#.
237
+
* We will **not** use `_` or `s_` as a prefix for internal or private field names
238
+
* We will use `camelCaseFieldName` for naming internal or private fields in both instance and static implementations
225
239
226
240
Read and follow our [Pull Request template](https://github.com/CommunityToolkit/Maui/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
To propose a change or new feature, review the guidance on [Submitting a New Feature](https://github.com/CommunityToolkit/Maui#submitting-a-new-feature).
231
245
232
246
#### Non-Starter Topics
247
+
233
248
The following topics should generally not be proposed for discussion as they are non-starters:
if(activityis not AndroidX.AppCompat.App.AppCompatActivitycomponentActivity)
36
+
{
37
+
Trace.WriteLine($"Unable to Modify Android StatusBar On ModalPage: Activity {activity.LocalClassName} must be an {nameof(AndroidX.AppCompat.App.AppCompatActivity)}");
38
+
return;
39
+
}
40
+
41
+
if(componentActivity.GetFragmentManager()is not AndroidX.Fragment.App.FragmentManagerfragmentManager)
42
+
{
43
+
Trace.WriteLine($"Unable to Modify Android StatusBar On ModalPage: Unable to retrieve fragment manager from {nameof(AndroidX.AppCompat.App.AppCompatActivity)}");
0 commit comments