Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Deserializing always results in a Success object. #165

Closed
MischaWeerwag opened this issue Feb 9, 2024 · 5 comments
Closed

Deserializing always results in a Success object. #165

MischaWeerwag opened this issue Feb 9, 2024 · 5 comments

Comments

@MischaWeerwag
Copy link

Im trying to use Ardalis Result in combination with an event bus which serializes the response type from within a command / query before returning it to the controller. This works as you would expect for Success messages, but not so much for others.

Example:

var a = JsonSerializer.Serialize(Result.NotFound("This is not found."));
// a = {"Value":null,"Status":5,"IsSuccess":false,"SuccessMessage":"","CorrelationId":"","Errors":["This is not found."],"ValidationErrors":[]}
var b = JsonSerializer.Deserialize<Result>(a);
// b =  (See Screenshot)
var c = JsonSerializer.Serialize(b);
//c = {"Value":null,"Status":0,"IsSuccess":true,"SuccessMessage":"","CorrelationId":"","Errors":[],"ValidationErrors":[]}
Screenshot 2024-02-09 at 10 13 59

This is very problematic as it looks like it is impossible to serialize / deserialise the result object.... Am I missing something or is this expected behaviour?

@MischaWeerwag
Copy link
Author

#166 fixes the issue!

@dandcg
Copy link

dandcg commented Feb 27, 2024

How long before this is resolved? I've just pulled the code - however still noticing that the Value isn't being deserialized as its generic - has anybody written some to cover this?

@ardalis
Copy link
Owner

ardalis commented Feb 28, 2024

Fixed by #166

@ardalis ardalis closed this as completed Feb 28, 2024
@ardalis
Copy link
Owner

ardalis commented Feb 28, 2024

@dandcg less than a day I guess. Estimates are easy in retrospect! :)

@dandcg
Copy link

dandcg commented Feb 28, 2024

Chhers man nice one!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants