Skip to content

Commit

Permalink
Added IQueryable<T> to AV1130 (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoelman authored Apr 28, 2022
1 parent 76a82fd commit eac2ba9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion _rules/1130.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ rule_category: member-design
title: Return interfaces to unchangeable collections
severity: 2
---
You generally don't want callers to be able to change an internal collection, so don't return arrays, lists or other collection classes directly. Instead, return an `IEnumerable<T>`, `IAsyncEnumerable<T>`, `IReadOnlyCollection<T>`, `IReadOnlyList<T>`, `IReadOnlySet<T>` or `IReadOnlyDictionary<TKey, TValue>`.
You generally don't want callers to be able to change an internal collection, so don't return arrays, lists or other collection classes directly. Instead, return an `IEnumerable<T>`, `IAsyncEnumerable<T>`, `IQueryable<T>`, `IReadOnlyCollection<T>`, `IReadOnlyList<T>`, `IReadOnlySet<T>` or `IReadOnlyDictionary<TKey, TValue>`.

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

0 comments on commit eac2ba9

Please sign in to comment.