EcoCode.Tool
1.3.0-beta6
EcoCode has been renamed to Creedengo
See the version list below for details.
dotnet tool install --global EcoCode.Tool --version 1.3.0-beta6
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local EcoCode.Tool --version 1.3.0-beta6
#tool dotnet:?package=EcoCode.Tool&version=1.3.0-beta6&prerelease
nuke :add-package EcoCode.Tool --version 1.3.0-beta6
EcoCode-C#
ecoCode is a collective project aiming to reduce environmental footprint of software at the code level. The goal of the project is to provide a list of static code analyzers to highlight code structures that may have a negative ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc.
ecoCode is based on evolving catalogs of good practices, for various technologies.
This set of Roslyn analyzers implements these catalogs as rules for scanning your C# projects.
⚠️ This is still a very early stage project. Any feedback or contribution will be highly appreciated. Please refer to the contribution section.
🚀 Getting Started
There are several ways you can use the ecoCode analyzers in your .Net projects:
- As a NuGet package : https://www.nuget.org/packages/EcoCode/.
- As a Visual Studio extension : https://marketplace.visualstudio.com/items?itemName=greencodeinitiative.ecoCode
- Coming soon : as a VS Code extension.
- Coming soon : as a .Net CLI Tool to scan existing code bases.
- Coming soon : a documentation on how to set up SonarScanner for .Net and display the EcoCode warnings in SonarQube.
🧩 Compatibility
Both the EcoCode NuGet package and Visual Studio extension target .Net Standard 2.0 and can be used in a wide range of projects. See Microsoft documentation for details about the supported .Net Frameworks in .Net Standard 2.0.
🌿 EcoCode Rules
Id | Description | Severity | Code fix |
---|---|---|---|
EC69 | Don’t call loop invariant functions in loop conditions | ⚠️ | ❌ |
EC72 | Don’t execute SQL queries in loops | ⚠️ | ❌ |
EC75 | Don’t concatenate strings in loops |
⚠️ | ❌ |
EC81 | Specify struct layouts |
⚠️ | ✔️ |
EC82 | Variable can be made constant | ℹ️ | ✔️ |
EC83 | Replace Enum ToString() with nameof |
⚠️ | ✔️ |
EC84 | Avoid async void methods |
⚠️ | ✔️ |
EC85 | Make type sealed |
ℹ️ | ✔️ |
EC86 | GC.Collect should not be called |
⚠️ | ❌ |
EC87 | Use collection indexer | ⚠️ | ✔️ |
EC88 | Dispose resource asynchronously | ⚠️ | ✔️ |
EC91 | Use Where before OrderBy |
⚠️ | ✔️ |
EC92 | Use Length to test empty strings |
⚠️ | ✔️ |
EC93 | Return Task directly |
ℹ️ | ✔️ |
🌿 Roslyn Rules
This plugin customizes the severity of certain Roslyn rules.
Id | Description | Old Severity | New Severity | Code fix |
---|---|---|---|---|
CA1825 | Avoid zero-length array allocations | ℹ️ | ⚠️ | ✔️ |
CA1827 | Do not use Count()/LongCount() when Any() can be used | ℹ️ | ⚠️ | ✔️ |
🤝 Contribution
See contribution on the central ecoCode repository.
🤓 Main contributors
See main contributors on the central ecoCode repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last updated | |
---|---|---|---|
1.5.3 | 165 | 1/1/2025 | |
1.5.3-beta1 | 118 | 1/1/2025 | |
1.5.2 | 193 | 11/9/2024 | |
1.5.1 | 237 | 8/1/2024 | |
1.5.0 | 230 | 7/13/2024 | |
1.5.0-beta1 | 161 | 7/13/2024 | |
1.4.0 | 264 | 6/24/2024 | |
1.3.0 | 244 | 6/24/2024 | |
1.3.0-beta6 | 191 | 6/24/2024 | |
1.3.0-beta5 | 234 | 6/24/2024 |