Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _pages/1100_MemberDesignGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ You generally don't want callers to be able to change an internal collection, so

**Exception:** Immutable collections such as `ImmutableArray<T>`, `ImmutableList<T>` and `ImmutableDictionary<TKey, TValue>` prevent modifications from the outside and are thus allowed.

### <a name="av1135"></a> Properties, arguments and return values representing strings or collections should never be `null` (AV1135) ![](/assets/images/1.png)
### <a name="av1135"></a> Properties, arguments and return values representing strings, collections or tasks should never be `null` (AV1135) ![](/assets/images/1.png)

Returning `null` can be unexpected by the caller. Always return an empty collection or an empty string instead of a `null` reference. When your member return `Task` or `Task<T>`, return `Task.CompletedTask` or `Task.FromResult()`. This also prevents cluttering your code base with additional checks for `null`, or even worse, `string.IsNullOrEmpty()`.

Expand Down
2 changes: 1 addition & 1 deletion _pages/Cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ NOTE: Requires Markdown Extra. See http://michelf.ca/projects/php-markdown/extra
* A property, method or local function should do only one thing (AV1115)
* Don't expose stateful objects through static members (AV1125)
* Return an `IEnumerable<T>` or `ICollection<T>` instead of a concrete collection class (AV1130)
* Properties, arguments and return values representing strings or collections should never be `null` (AV1135)
* Properties, arguments and return values representing strings, collections or tasks should never be `null` (AV1135)
* Define parameters as specific as possible (AV1137)
</td>
<td class="column">
Expand Down