Skip to content

Consider returning A List or Enumerable for errors? #38

Description

@ziaulhasanhamim

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions