Resharper: How do I apply the [NotNull] or [CanBeNull] annotation implicitly with a different attribute?

In our code, we have our own injection environment, which includes dependency injection, for example:

public class MyClass { [Component("ComponentName1")] // means [NotNull] public MyType NotNullComponent{ get; set; } [OptionalComponent("ComponentName2")] // means [CanBeNull] public MyType CanBeNullComponent { get; set; } } 

We do not want to add [CanBeNull] or [NotNull] , since it duplicates the semantics of the [Component] and [OptionalComponent] attributes.

Is it possible for Resharper to know the semantics of user attributes to help static analysis?

+5
source share
1 answer

Now you can implicitly use [NotNull] anyway by enabling "Implicitly" in Code Inspection -> Settings

If you do not specify [CanBeNull], everything will be considered invalid.

enter image description here

0
source

Source: https://habr.com/ru/post/1243968/


All Articles