{"id":27235549,"url":"https://github.com/green-code-initiative/creedengo-csharp","last_synced_at":"2026-05-10T19:57:52.284Z","repository":{"id":227249914,"uuid":"744197847","full_name":"green-code-initiative/creedengo-csharp","owner":"green-code-initiative","description":"Reduce the environmental footprint of your C# software programs","archived":false,"fork":false,"pushed_at":"2025-02-08T20:46:14.000Z","size":339,"stargazers_count":15,"open_issues_count":1,"forks_count":13,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-09T19:54:56.665Z","etag":null,"topics":["csharp","ecodesign"],"latest_commit_sha":null,"homepage":"https://ecocode.io","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-code-initiative.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-16T20:11:59.000Z","updated_at":"2025-04-03T14:07:00.000Z","dependencies_parsed_at":"2024-11-09T03:23:05.898Z","dependency_job_id":"e465806d-b533-4565-8b8e-340ee1143e3e","html_url":"https://github.com/green-code-initiative/creedengo-csharp","commit_stats":null,"previous_names":["green-code-initiative/ecocode-csharp","green-code-initiative/creedengo-csharp"],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-code-initiative%2Fcreedengo-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-code-initiative%2Fcreedengo-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-code-initiative%2Fcreedengo-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-code-initiative%2Fcreedengo-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-code-initiative","download_url":"https://codeload.github.com/green-code-initiative/creedengo-csharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248254424,"owners_count":21073086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","ecodesign"],"created_at":"2025-04-10T16:47:13.249Z","updated_at":"2026-05-10T19:57:52.276Z","avatar_url":"https://github.com/green-code-initiative.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Creedengo on NuGet](https://img.shields.io/nuget/v/Creedengo.svg)](https://www.nuget.org/packages/Creedengo/) [![Creedengo on NuGet](https://img.shields.io/nuget/dt/Creedengo)](https://www.nuget.org/packages/Creedengo/)\n\nCreedengo-C#\n===========\n\n_creedengo_ 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.\n\n_creedengo_ is based on evolving catalogs of [good practices](https://github.com/green-code-initiative/creedengo-rules-specifications/tree/main/docs/rules), for various technologies. This set of Roslyn analyzers implements these catalogs as rules for scanning your C# projects.\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CODE_OF_CONDUCT.md)\n\n🚀 Getting Started\n------------------\n\nThere are several ways you can use the creedengo C# analyzers in your .Net projects:\n1. As a [NuGet package](#-nuget-package)\n2. As a [.NET tool](#-net-tool)\n3. As an [analyzer for SonarQube](#-analyzer-for-sonarqube).\n\n🧩 NuGet package\n-----------------\nThe package is available on nuget.org at this address : https://www.nuget.org/packages/Creedengo, and can be added to your projects/solutions like any NuGet package. Once referenced and restored, the creedengo analyzers are automatically integrated in your IDE/compilation process, and will list any applicable info/alert.\n\nPre-requisite : .Net Standard 2.0, which can be used in a wide range of projects. See [Microsoft documentation](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version) for details about the supported Frameworks.\n\n🧩 .Net tool\n-----------------\nThe .Net tool is available on nuget.org at this address : https://www.nuget.org/packages/Creedengo.Tool, and can be fetched on your machine using the following command :\n\n`dotnet tool install --global Creedengo.Tool`\n\nSee [.Net tools documentation](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools) for additional information.\n\nOnce installed, you can launch an analyzis on an existing codebase like this :\n\n`creedengo-cli analyze path/to/mySolution.sln path/to/myReport.html`.\n\nThe file to analyze can be a .sln, a .slnx or a .csproj. The report format depends on it's required extension, the following are currently supported : .html, .json and .csv.\n\nPre-requisite : .Net 8 SDK.\n\n🧩 Analyzer for SonarQube\n-----------------\nCreedengo C# can use [SonarScanner for .Net](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner-for-dotnet/) to integrate with [SonarQube](https://www.sonarsource.com/products/sonarqube/), and uses a custom import addition to enrich what is reported to Sonar (severity, description, url page, category, and so on). See our [dedicated repository](https://github.com/green-code-initiative/creedengo-csharp-sonarqube) for more information.\n\n🌿 Creedengo Rules\n-------------------\n\n|Id|Description|Severity|Code fix|\n|--|-----------|:------:|:------:|\n|[GCI69](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI69/csharp/GCI69.asciidoc)|Don’t call loop invariant functions in loop conditions|⚠️|❌|\n|[GCI72](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI72/csharp/GCI72.asciidoc)|Don’t execute SQL queries in loops|⚠️|❌|\n|[GCI75](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI75/csharp/GCI75.asciidoc)|Don’t concatenate `strings` in loops|⚠️|❌|\n|[GCI81](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI81/csharp/GCI81.asciidoc)|Specify `struct` layouts|⚠️|✔️|\n|[GCI82](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI82/csharp/GCI82.asciidoc)|Variable can be made constant|ℹ️|✔️|\n|[GCI83](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI83/csharp/GCI83.asciidoc)|Replace Enum `ToString()` with `nameof`|⚠️|✔️|\n|[GCI84](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI84/csharp/GCI84.asciidoc)|Avoid `async void` methods|⚠️|✔️|\n|[GCI85](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI85/csharp/GCI85.asciidoc)|Make type `sealed`|ℹ️|✔️|\n|[GCI86](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI86/csharp/GCI86.asciidoc)|`GC.Collect` should not be called|⚠️|❌|\n|[GCI87](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI87/csharp/GCI87.asciidoc)|Use collection indexer|⚠️|✔️|\n|[GCI88](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI88/csharp/GCI88.asciidoc)|Dispose resource asynchronously|⚠️|✔️|\n|[GCI91](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI91/csharp/GCI91.asciidoc)|Use `Where` before `OrderBy`|⚠️|✔️|\n|[GCI92](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI92/csharp/GCI92.asciidoc)|Use `Length` to test empty `strings`|⚠️|✔️|\n|[GCI93](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI93/csharp/GCI93.asciidoc)|Return `Task` directly|ℹ️|✔️|\n|[GCI95](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI95/csharp/GCI95.asciidoc)|Use `is` operator instead of `as` operator|ℹ️|✔️|\n\n🌿 Customized Roslyn Rules\n-------------------\n\nCreedengo C# customizes the severity of the following native Roslyn rules.\n\n|Id|Description|Old Severity|New Severity|\n|--|-----------|:----------:|:----------:|\n|[CA1001](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1001)|Types that own disposable fields should be disposable|💤|⚠️|\n|[CA1802](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1802)|Use Literals Where Appropriate|💤|⚠️|\n|[CA1805](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1805)|Do not initialize unnecessarily|💤|⚠️|\n|[CA1813](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1813)|Avoid unsealed attributes|💤|⚠️|\n|[CA1816](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1816)|Call GC.SuppressFinalize correctly|ℹ️|⚠️|\n|[CA1821](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1821)|Remove empty finalizers|ℹ️|⚠️|\n|[CA1822](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822)|Mark members as static|ℹ️|⚠️|\n|[CA1824](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1824)|Mark assemblies with NeutralResourcesLanguageAttribute|ℹ️|⚠️|\n|[CA1825](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1825)|Avoid zero-length array allocations|ℹ️|⚠️|\n|[CA1826](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1826)|Use property instead of Linq Enumerable method|ℹ️|⚠️|\n|[CA1827](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1827)|Do not use Count()/LongCount() when Any() can be used|ℹ️|⚠️|\n|[CA1828](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1828)|Do not use CountAsync/LongCountAsync when AnyAsync can be used|ℹ️|⚠️|\n|[CA1829](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1829)|Use Length/Count property instead of Enumerable.Count method|ℹ️|⚠️|\n|[CA1830](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1830)|Prefer strongly-typed Append and Insert method overloads on StringBuilder|ℹ️|⚠️|\n|[CA1832](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1832)|Use AsSpan or AsMemory instead of Range-based indexers for getting ReadOnlySpan or ReadOnlyMemory portion of an array|ℹ️|⚠️|\n|[CA1833](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1833)|Use AsSpan or AsMemory instead of Range-based indexers for getting Span or Memory portion of an array|ℹ️|⚠️|\n|[CA1834](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1834)|Use StringBuilder.Append(char) for single character strings|ℹ️|⚠️|\n|[CA1835](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1835)|Prefer the memory-based overloads of ReadAsync/WriteAsync methods in stream-based classes|ℹ️|⚠️|\n|[CA1836](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1836)|Prefer IsEmpty over Count when available|ℹ️|⚠️|\n|[CA1837](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1837)|Use Environment.ProcessId instead of Process.GetCurrentProcess().Id|ℹ️|⚠️|\n|[CA1838](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1838)|Avoid StringBuilder parameters for P/Invokes|💤|⚠️|\n|[CA1839](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1839)|Use Environment.ProcessPath instead of Process.GetCurrentProcess().MainModule.FileName|ℹ️|⚠️|\n|[CA1840](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1840)|Use Environment.CurrentManagedThreadId instead of Thread.CurrentThread.ManagedThreadId|ℹ️|⚠️|\n|[CA1841](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1841)|Prefer Dictionary Contains methods|ℹ️|⚠️|\n|[CA1842](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1842)|Do not use 'WhenAll' with a single task|ℹ️|⚠️|\n|[CA1843](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1843)|Do not use 'WaitAll' with a single task|ℹ️|⚠️|\n|[CA1844](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1844)|Provide memory-based overrides of async methods when subclassing 'Stream'|ℹ️|⚠️|\n|[CA1845](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1845)|Use span-based 'string.Concat'|ℹ️|⚠️|\n|[CA1846](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1846)|Prefer AsSpan over Substring|ℹ️|⚠️|\n|[CA1847](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1847)|Use String.Contains(char) instead of String.Contains(string) with single characters|ℹ️|⚠️|\n|[CA1850](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1850)|Prefer static HashData method over ComputeHash|ℹ️|⚠️|\n|[CA1853](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1853)|Unnecessary call to 'Dictionary.ContainsKey(key)'|ℹ️|⚠️|\n|[CA1854](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1854)|Prefer the IDictionary.TryGetValue(TKey, out TValue) method|ℹ️|⚠️|\n|[CA1855](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1855)|Use Span\u003cT\u003e.Clear() instead of Span\u003cT\u003e.Fill()|ℹ️|⚠️|\n|[CA1858](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1858)|Use StartsWith instead of IndexOf|ℹ️|⚠️|\n|[CA1859](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859)|Prefer concrete types when possible for improved performance|ℹ️|⚠️|\n|[CA1860](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1860)|Avoid using 'Enumerable.Any()' extension method|ℹ️|⚠️|\n|[CA1863](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1863)|Use 'CompositeFormat'|💤|⚠️|\n|[CA1864](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1864)|Prefer the 'IDictionary.TryAdd(TKey, TValue)' method|ℹ️|⚠️|\n|[CA1865-7](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1865-ca1867)|Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char|ℹ️|⚠️|\n|[CA1868](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1868)|Unnecessary call to 'Contains' for sets|ℹ️|⚠️|\n|[CA1869](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1869)|Cache and reuse 'JsonSerializerOptions' instances|ℹ️|⚠️|\n|[CA1870](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1870)|Use a cached 'SearchValues' instance|ℹ️|⚠️|\n|[CA1871](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1871)|Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'|ℹ️|⚠️|\n|[CA1872](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1872)|Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'|ℹ️|⚠️|\n|[CA2009](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2009)|Do not call ToImmutableCollection on an ImmutableCollection value|ℹ️|⚠️|\n|[CA2215](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2215)|Dispose methods should call base class dispose|💤|⚠️|\n|[CA2218](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2218)|Override GetHashCode on overriding Equals|ℹ️|⚠️|\n|[CA2251](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2251)|Use String.Equals over String.Compare|💤|⚠️|\n|[CA2264](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2264)|Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'|ℹ️|⚠️|\n\n🤝 Contribution\n---------------\n\nSee [contribution](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CONTRIBUTING.md) on the central repository.\n\n🤓 Main contributors\n--------------------\n\nSee [main contributors](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/README.md#-main-contributors) on the central repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-code-initiative%2Fcreedengo-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-code-initiative%2Fcreedengo-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-code-initiative%2Fcreedengo-csharp/lists"}