Why we should not use EnsureSuccessStatusCode()?

[11/05/2020 5:44 PM] Amber R: Hi Ketan, the issue with throwing a specific exception is that we have to parse the error response and throw an exception based on that

For eg. if call in GetCollections method fails, if we throw a custom exception when it’s not success status code, isn’t it the same as as using .EnsureSuccessStatusCode()? Just the message will be different since it’s custom exception, but we still won’t know why the call fail


I got this message from one of my colleague. We were argueing on why using EnsureSuccessCode() is a bad idea.

More …

CA2227 : Collection properties should be read only

Why?

MSDN says, A writable collection property allows a user to replace the collection with a completely different collection. A read-only property stops the collection from being replaced, but still allows the individual members to be set. If replacing the collection is a goal, the preferred design pattern is to include a method to remove all the elements from the collection, and a method to repopulate the collection.

More …