Qodana for .NET

Qodana for .NET is based on Rider and provides static analysis for .NET projects. It brings all the smarts from Rider, which help you:
Detect anomalous code and probable bugs
Eliminate dead code
Highlight spelling problems
Improve overall code structure
Introduce coding best practices
Upload inspection results to Qodana Cloud
Qodana for .NET provides inspections for the C, C++, C#, VB.NET, JavaScript, and TypeScript programming languages. C and C++ inspections of Qodana for .NET are limited by projects containing .sln
files.
Qodana for .NET provides inspections for the following technologies.
Programming languages | C# C C++ JavaScript TypeScript VB.NET |
Markup languages | CSS HTML JSON and JSON5 RELAX NG T4 XML XPath XSLT YAML |
Scripting languages | Shell script |
Databases and ORM | MongoJS MySQL Oracle PostgreSQL SQL SQL server |
Build management | MSBuild |
Frameworks and libraries | .NET Core Handlebars/Mustache Less Node.JS NUnit Pug/Jade Sass/SCSS Unity Unreal Engine Vue Xunit |
Here, C and C++ inspections are applicable for projects containing .sln
files.
The Qodana for .NET linter provides the following Qodana features:
Feature | Available under licenses |
---|---|
Ultimate and Ultimate Plus | |
Ultimate and Ultimate Plus |
Qodana for .NET is suitable for analyzing .NET Core projects and provides the following SDK versions:
3.0.103
6.0.405
7.0.102
All SDK versions are stored in the /usr/share/dotnet/sdk
directory of the Qodana for .NET container filesystem.
note
Functionality of .NET Framework-based project analysis will be added in future versions of the linter. Currently, it is not recommended to inspect projects that require .NET Framework.
In case a project requires a different version of the SDK, you can set it up before running the analysis using the bootstrap
field in the qodana.yaml
file. For example, this command will install the required version of the SDK that is specified in the global.json
file and located in the root of your project:
bootstrap: curl -fsSL https://dot.net/v1/dotnet-install.sh |
bash -s -- --jsonfile /data/project/global.json -i /usr/share/dotnet
By default, Qodana tries to locate and employ a single solution file, or, if no solution file is present, it tries to find a project file. If your project contains multiple solution files, you need to specify the exact file name using the --property
option. For example, to make Qodana always analyze the MySolution.sln
solution file, you can use:
--property=qodana.net.solution=MySolution.sln
Alternatively, you can specify the solution file name in the qodana.yaml
file using the solution
option:
dotnet:
solution: MySolution.sln
If you project contains no solution files and multiple project files, you need to specify the exact file name of a project. For example, for the MyProject.csproj
project file it can be:
--property=qodana.net.project=MyProject.csproj
Alternatively, you can specify the project file name in the qodana.yaml
file using the project
option:
dotnet:
project: MyProject.csproj
A solution configuration defines which projects in the solution are build, and which project configurations are used for specific projects within the solution.
Each newly-created solution includes the Debug
and Release
configurations, which can be complemented by your custom configurations.
You can switch configurations of the current solution using the --property
configuration option. For example, use this to switch to the Release
configuration:
--property=qodana.net.configuration=Release
Alternatively, you can specify the configuration in qodana.yaml
:
dotnet:
configuration: Release
By default, the solution platform is set to Any CPU
.You can override this using the --property
option:
--property=qodana.net.platform=x86
Alternatively, you can specify the platform in qodana.yaml
:
dotnet:
platform: x86
Qodana provides two options for local analysis of your code. Qodana CLI is the easiest option to start. Alternatively, you can use the Docker command from the Docker image tab.
Assuming that you have already installed Qodana CLI on your machine, you can run this command in the project root directory:
$qodana scan \ -e QODANA_TOKEN="<cloud-project-token>" \ -l jetbrains/qodana-dotnet:2023.2 \ --show-report
Here, the QODANA_TOKEN
variable refers to the project token.
To start, pull the image from Docker Hub (only necessary to get the latest version):
$docker pull jetbrains/qodana-dotnet:2023.2
Start local analysis with source-directory
pointing to the root of your project and QODANA_TOKEN
referring to the project token:
$docker run --rm -it \ -v <source-directory>/:/data/project/ \ -e QODANA_TOKEN="<cloud-project-token>" \ -p 8080:8080 \ jetbrains/qodana-dotnet:2023.2 \ --show-report
Open http://localhost:8080
in your browser to examine inspection results. Here, you can also reconfigure the analysis, see the Inspection report section for details. When done, you can stop the web server by pressing Ctrl-C in the console.
Thanks for your feedback!