Please add [CanBeNull] attribute to some methods
See original GitHub issueFor example this method:
[Pure]
public static TValue GetValueOrDefault<TKey, TValue>([NotNull] this Dictionary<TKey, TValue> dictionary, TKey key)
{
return DictionaryExtensions.GetValueOrDefault<TKey, TValue>(dictionary, key, default (TValue));
}
should have [CanBeNull] attribute applied, because it can return null when TValue is a class. Otherwise ReSharper does not help catch possible null reference exception.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
C#: How to Implement and use a NotNull and CanBeNull ...
I want to let programmers and myself know that a method does not want null and if you do send null to it...
Read more >Code annotation attributes | ReSharper Documentation
Indicates that the value of the marked element could be null sometimes, so checking for null is required before its usage. Example. [CanBeNull] ......
Read more >Do you use attributes like CanBeNull and NotNull for every ...
I would like to know that you use these attributes and how much are they ... and NotNull for every parameter objects and...
Read more >Rider always convert '?' into [CanBeNull]
Say i write this method: public IResult DoAction(IPlayer player, ... that IActor can be null, our convention is to basically add '?'
Read more >Migrate from Jetbrains.Annotations [NotNull] / [CanBeNull] to ...
A screenshot demonstrating usage of the [CanBeNull] attribute in C#. Using the [NotNull] attribute helps notice a mistake. Here, null is not a ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MozgC I’ve marked only overloads that have no selector or explicit default value arg. If this is not what you want - let me know:)
@Lexey, OP is talking about marking the return value with
[CanBeNull]
. it looks reasonable for me.@MozgC, will do. BTW doing a PR would work too:)