There is no way to verify that a type with a null type will not return null , however, consider that the structure is stable in terms of code changes. I will strive to make an informed decision by looking at how the property or method you invoke works using ILSpy or JustDecompile .
In your example, it would turn out that null cannot be returned, since the constructor for ImageFormat takes a Guid and assigns it to a private field.
Depending on what you are doing with this property, it is worth checking:
- That a
StatusException not StatusException to access the property. - That
ImageFormat is equal to the format you expect, since it can be an image format that neither GdiPlus nor .NET are aware of.
source share