ardalis / Result

A result abstraction that can be mapped to HTTP response codes if needed.
MIT License
866 stars 107 forks source link

Proposal: Add map extension to convert result values #97

Closed KyleMcMaster closed 2 years ago

KyleMcMaster commented 2 years ago

Fixes #81

Possibly fixes issue #94. I prefer separating Map and ToActionResult into different methods based on SRP since it is ToActionResult's responsibility for mapping Result<T> -> ActionResult<T> rather than mapping Result<T> -> Result<K> -> ActionResult<K>. It is possible consumers may want to change a Result's Value type separately of producing an ActionResult. This approach avoids the need for any IMapper dependency.

joncoelloaccess commented 2 years ago

@KyleMcMaster looks great, thanks :)

KyleMcMaster commented 2 years ago

Fixes #94

github-actions[bot] commented 2 years ago

Code Coverage

Package Line Rate Branch Rate Complexity
Ardalis.Result.SampleWeb 62% 50% 38
Ardalis.Result.AspNetCore 67% 70% 27
Ardalis.Result 33% 22% 60
Ardalis.Result.Sample.Core 25% 32% 48
Ardalis.Result.FluentValidation 0% 0% 6
Summary 42% (243 / 573) 43% (29 / 68) 179