{"id":22191530,"url":"https://github.com/deniszykov/code-contracts-remover","last_synced_at":"2025-07-26T22:31:31.310Z","repository":{"id":56054107,"uuid":"60240318","full_name":"deniszykov/code-contracts-remover","owner":"deniszykov","description":"tool for removing .net code contracts from project","archived":false,"fork":false,"pushed_at":"2024-01-17T13:28:36.000Z","size":122,"stargazers_count":14,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-09T19:17:57.661Z","etag":null,"topics":["code-cleaning","code-contracts","roslyn"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deniszykov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-06-02T07:01:40.000Z","updated_at":"2024-07-16T20:45:53.000Z","dependencies_parsed_at":"2024-01-17T15:31:13.052Z","dependency_job_id":"3b9032c4-fa37-4ff0-a347-68e69b7abcd1","html_url":"https://github.com/deniszykov/code-contracts-remover","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniszykov%2Fcode-contracts-remover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniszykov%2Fcode-contracts-remover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniszykov%2Fcode-contracts-remover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniszykov%2Fcode-contracts-remover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deniszykov","download_url":"https://codeload.github.com/deniszykov/code-contracts-remover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227724168,"owners_count":17810036,"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":["code-cleaning","code-contracts","roslyn"],"created_at":"2024-12-02T12:16:29.209Z","updated_at":"2024-12-02T12:16:29.845Z","avatar_url":"https://github.com/deniszykov.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n============\nTool for removing .NET Code Contracts from source code. \nCurrently only C# is supported. I will gladly accept PR with VB support.\n\n.NET 4.7.1 is required to run this application.\n\nInstallation\n============\n```\nInstall-Package CodeContractsRemover\n```\nor\n```\nDownload and un-zip from https://www.nuget.org/api/v2/package/CodeContractsRemover \n```\n\nUsage\n============\nTool is located at \"PROJECT_DIR/packages/CodeContractsRemover.VERSION/tools/\".\n\n```bash\nCodeContractsRemover.exe \u003cConvert|Stats\u003e \u003cdirectoryPath\u003e [--searchPattern *.cs *.csproj] [--encoding utf-8] [--ignorePattern .svn/ ]\n```\nExample\n```bash\nCodeContractsRemover.exe Convert ./myproject\n```\n\nTo run using [mono](http://www.mono-project.com/download/#download-mac) on Mac OS X\n```bash\n/Library/Frameworks/Mono.framework/Commands/mono code_contracts_remover.exe Convert ./myproject\n```\n\nTo run using [mono](http://www.mono-project.com/download/#download-lin) on Linux\n```bash\n/usr/bin/mono code_contracts_remover.exe Convert ./myproject\n```\n\n## Modes\n\n#### Mode - Convert\n- Converts all [Contract.Requires](https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract.requires(v=vs.110).aspx) to \"if(!x) throw new ArgumentException()\" pattern at the beginning of method/property/constructor.\n- Converts all [Contract.Ensures](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.contract.ensures?view=netcore-3.1) to \"if(!x) throw new InvalidOperationException()\" pattern before each return inside method/property/constructor.\n- Converts all [Contract.Assert](https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract.assert(v=vs.110).aspx), [Contract.Assume](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.contract.assume?view=netcore-3.1) and [Contract.Invariant](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.contract.invariant?view=netcore-3.1) to \"if(!x) throw new InvalidOperationException()\" pattern.\n- Invokes invariant methods before each return incide method/property/constructor.\n- Preserves all other [Contract](https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract(v=vs.110).aspx) invocations (including Attributes and Contract classes).\n- Removes CodeContract properties and constants from project files\n\n~~#### Mode - Remove~~\n- Removes any [Contract](https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract(v=vs.110).aspx) invocations.\n- Invariant methods are preserved\n- Attributes and Contract classes are removed\n- Removes CodeContract properties and constants from project files\n\n#### Mode - Stats\n- Collects statistics about how [Contracts](https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract(v=vs.110).aspx) are used. Example of result:\n```\n[ContractClassFor]                                \t  1\n[ContractInvariantMethod]                         \t  2\nContract.Assert                                   \t  1\nContract.Ensures                                  \t  6\nContract.Invariant                                \t  2\nContract.Requires                                 \t  6\nContract.Result                                   \t  5\n```\n\n## Annotation modes\n\nIn Convert mode [Jet Brains annotations](https://blog.jetbrains.com/dotnet/2018/05/02/improving-rider-resharper-code-analysis-using-jetbrains-annotations/) ([NotNull]) can be added to class members. Jet Brains annotations are added using [JetBrains.Annotations NuGet package](https://www.nuget.org/packages/JetBrains.Annotations/).\n\n#### Mode - None\nDon't add annotations\n\n#### Mode - Add\nInclude annotations only for work in Visual Studio/Rider before compilation. When project is compiled, annotations would be removed. When dll is referenced into other project, Rider/Re# wouldn't show hints. This mode is recommended for applications. Read more on [Jet Brains site](https://blog.jetbrains.com/dotnet/2015/08/12/how-to-use-jetbrains-annotations-to-improve-resharper-inspections/).\n\n#### Mode - IncludeIntoBinaries\nAnnotations will be included into binaries, so Rider/Re# would show hints before and after compilation (when binary is referenced into other project). This mode is recommended for packages. Read more on [Jet Brains site](https://blog.jetbrains.com/dotnet/2015/08/12/how-to-use-jetbrains-annotations-to-improve-resharper-inspections/).\n\t\t\n# Contributors\n * @ishatalkin\n * @mgaffigan\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeniszykov%2Fcode-contracts-remover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeniszykov%2Fcode-contracts-remover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeniszykov%2Fcode-contracts-remover/lists"}