C#8 Nullable types (?) vs ReSharper nullability annotations

Viewed 62

I'm working on an ABP project and noticed that ReSharper auto-formats a nullable type like string? to [CanBeNull] string.

Is there still any benefit to using ReSharper Annotations over C# 8 features?

1 Answers

The attributes [CanBeNull] etc. were ReSharper's way of implementing nullability annotations. This may be my opinion, but going forward, I believe these are obsolete. If you use C# 8 nullable types, these attributes are confusing and conflicting, too. Just delete the ReSharper Annotations.cs file from your project and change the code to use the new ? syntax.

Additionally, you might want to enable the ReSharper configuration option "Use nullable annotation instead of an attribute". I'm not sure whether there are more similar options, but I have never seen an automatic replacement as you describe it above.

Related