Custom null checking methods - Contract annotations not working Follow
Hello!
I have implemented 'Contract Annotations' to perform custom 'null checks' - however my method still shows that a possible null reference may occur.
Am I doing anything wrong?
Please sign in to leave a comment.
Since you're using nullable reference types, you should probably use the built-in attributes instead of the JetBrains annotations.
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.notnullwhenattribute?view=net-6.0
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis
Specifically:
Thank you! I will take a look at this. I was not aware of the ''[NotNullWhen(bool)]' attribute.
I will take a look at this and get back to you. Thank you!
Richard Deeming, thank you so much for your help! :)