C# 7.0 and 7.1 support in ReSharper – How this affects other ReSharper features
Over the past days, we have been blogging about ReSharper support for C# 7.0 and C# 7.1.
Today, let’s conclude with a final part around how ReSharper understands the new syntax and constructs that C# 7.0 and C# 7.1 bring, and ties them into existing and new inspections, quick-fixes, navigation and refactorings.
In this series:
- Out variables
- Throw expressions
- Expression-bodied “everything”
- Async main
- Default literal
- Pattern matching with generics
- Improving ReSharper
Improving existing ReSharper features
Adding support for new C# language features isn’t just about adding support to the language parser or adding new quick-fixes. Work indeed starts with adding the language features to the PSI (Program Structure Interface) that ReSharper uses internally, but we also have to integrate these language features into existing ReSharper features you know and love.
For example adding
out variable declarations to the PSI lets us integrate them into existing refactorings like Rename. With
throw expressions as well as the
default literal introducing new types of null checks, adding these to the PSI and updating existing code anlysis allow ReSharper to detect potential
NullReferenceException in our existing code and in new C# 7.0 or C# 7.1 code.
Adding expression-bodied properties to our PSI allows the existing Convert to Auto-Property code analysis, quick-fix and refactoring to be updated with functionality that works on block bodies as well as expression bodies:
Existing and new code analysis and code style rules for C# 7.0 and C# 7.1 language features become part of Solution-Wide Analysis and the Inspect This… (Ctrl+Shift+Alt+A) action. What if we want to use the
default literal everywhere in our solution? What if we want to spot opportunities to use pattern matching?
So if we run code analysis on our current solution or project, ReSharper will tell us we have a Redundant Type Specification when we could be using the new
default literal in our code:
We can also run an inspection from the editor, using the Find similar… submenu’s:
The new syntax also lights up in code style settings – e.g. since any class member can now be expression-bodied, we can now configure code styles to use them everywhere, or only for properties and never for event handlers, etc.
In another example, Value/Call Tracking automatically got support for expression-bodied constructors so we can track incoming calls to our
Subscribe to Blog updates
Thanks, we've got you!
Another Look into the Future with Rider’s Predictive Debugger
In the 2023.2 release cycle, we’ve introduced the Predictive Debugger in ReSharper, which gives you predictions about code paths and variables beyond the current execution pointer. We’ve written extensively about its advantages compared to alternative debugging strategies like thorough thinking, log…
Visualize Entity Framework Relationships and Additional Query Analysis in ReSharper 2023.3
A lot of teams are using Entity Framework or EF Core to work with their database. As an Object-Relational Mapper (ORM), it bridges objects in code to a relational database model, so that as a developer you don’t have to worry too much about the actual database. We all know: that’s not entirely tr…
Automatically Analyze ASP.NET Core Performance With Dynamic Program Analysis
Slow web pages may make your users or customers abandon your web application, even before they’ve had a proper look at it. You’ve likely also been frustrated working with a web application that is slow to load. The good news is that the latest versions of ReSharper and JetBrains Rider’s Dynamic P…
OSS Power-Ups: MassTransit – Webinar Recording
The recording of our webinar, OSS Power-Ups: MassTransit, with Chris Patterson, is available. This was the thirteenth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.…