Code Contracts on .NET Core
I'd really like to add argument guards all over my code where if a passed parameter is null you check and throw an argument exception. This is a very common pattern. I've been reading about code contracts and it seems much cleaner to use them but it looks like the project is dead. What do you use to accomplish what I'm trying to do? I looked at fluent assertions which looks very slick but people say not to use it in production. I strongly prefer something Microsoft blessed or something with a large community support which makes me not want to use the null guard project.
Is there a plugin like resharper that will add these checks?
This is the article on code contracts https://visualstudiomagazine.com/articles/2017/04/01/reconsider-using-contracts.aspx?m=1
I also found this https://github.com/Fody/NullGuard
*EDIT I also want to be able to check all of the properties on a passed object for sane values. I'd like to not have 10 if not null checks I have to write. Fluent assertions makes this clean.
0 comments:
Post a Comment