DamianEdwards / DamianEdwards/MiniValidation
Consider returning A List or Enumerable for errors?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 390
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Currently 'TryValidate' method returns IDictionary<string, string[]>. If we look at the implementation of the 'TryValidate' method, it first creates Dictionary<string, List<string>> then it maps it to Dictionary<string, string[]> using the ToArray method. But can't it just return the Dictionary<string, List<string>>? What's the problem with it? Mapping it using ToArray causes it to create new arrays,
It's not like arrays are immutable. For immutable behavior IEnumerable or even better IReadOnlyCollection would be much better as they won't allocate new collections.
Maybe I'm missing something on the intention of returning arrays. Let me know.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the TryValidate implementation and its public return type, then inspect how callers consume IDictionary<string, string[]> and how the intermediate Dictionary<string, List> is converted. Compare the allocation and compatibility implications of the proposed return types; done requires a decided public API direction and agreement on its behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100