In our previous blog post, we looked at an example of using JetBrains Annotations. We saw they are an easy way to improve Rider (and ReSharper’s) code analysis, code completion and navigation by adding some simple hints in our code, in the form of attributes. In this post, we’ll look a bit more at the background: what are these annotations? And how do we add them to our source code?
In this series:
- Improving Rider and ReSharper code analysis using JetBrains Annotations
- What are JetBrains Annotations – and how to get them?
- Better null checks, string formatting and path completion with JetBrains Annotations
we look at how to add JetBrains Annotations to our code, let’s take one step back and look at what they are.
What are JetBrains Annotations?
Rider and ReSharper’s code analysis and inspections are very smart on their own and help find code smells, dead code, potential compile time or run time errors, and more.
We have already seen that we can make this mechanism smarter by telling Rider and ReSharper what we mean. In our previous post, we saw that the ReSharper engine knew we were working with strings, but only we as the author of that code knew these strings were controllers and actions. Code analysis may warn us that a value can be null, but maybe the underlying code never returns null at all. Only one way to tell the engine: annotations. Continue reading