All Projects → deniszykov → code-contracts-remover

deniszykov / code-contracts-remover

Licence: MIT license
tool for removing .net code contracts from project

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to code-contracts-remover

Cs2cpp
C# to C++ transpiler (Cs2Cpp) (Powered by Roslyn)
Stars: ✭ 155 (+1092.31%)
Mutual labels:  roslyn
Roslyn Security Guard
Roslyn analyzers that aim to help security audit on .NET applications.
Stars: ✭ 214 (+1546.15%)
Mutual labels:  roslyn
IncludeToolbox
Visual Studio extension to format, prune, and inspect include directives.
Stars: ✭ 48 (+269.23%)
Mutual labels:  code-cleaning
Roslynator
A collection of 500+ analyzers, refactorings and fixes for C#, powered by Roslyn.
Stars: ✭ 2,221 (+16984.62%)
Mutual labels:  roslyn
Scriptcs
Write C# apps with a text editor, nuget and the power of Roslyn!
Stars: ✭ 2,343 (+17923.08%)
Mutual labels:  roslyn
Csharp Source Generators
A list of C# Source Generators (not necessarily awesome) and associated resources: articles, talks, demos.
Stars: ✭ 218 (+1576.92%)
Mutual labels:  roslyn
Peachpie
PeachPie - the PHP compiler and runtime for .NET and .NET Core
Stars: ✭ 1,945 (+14861.54%)
Mutual labels:  roslyn
icsharp.kernel
Roslyn based C# kernel for Jupyter Notebook
Stars: ✭ 26 (+100%)
Mutual labels:  roslyn
Seriloganalyzer
Roslyn-based analysis for code using the Serilog logging library. Checks for common mistakes and usage problems.
Stars: ✭ 214 (+1546.15%)
Mutual labels:  roslyn
Norns
dotnet core aop static weaving on roslyn
Stars: ✭ 23 (+76.92%)
Mutual labels:  roslyn
Meziantou.analyzer
A Roslyn analyzer to enforce some good practices in C#.
Stars: ✭ 189 (+1353.85%)
Mutual labels:  roslyn
Pluginframework
Everything is a Plugin in .NET
Stars: ✭ 197 (+1415.38%)
Mutual labels:  roslyn
Roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
Stars: ✭ 15,296 (+117561.54%)
Mutual labels:  roslyn
Dotnetomdgenerator
A Roslyn-based cross-platform tool that generates an object model diagram from a set of C# source files or assemblies
Stars: ✭ 160 (+1130.77%)
Mutual labels:  roslyn
Analyzers
C# code analyzers
Stars: ✭ 18 (+38.46%)
Mutual labels:  roslyn
Curl To Csharp
curl to C# converter
Stars: ✭ 153 (+1076.92%)
Mutual labels:  roslyn
Retyped
Access 3600+ libraries from C# and let Bridge.NET compile your project into JavaScript.
Stars: ✭ 216 (+1561.54%)
Mutual labels:  roslyn
DynamicRun
Dynamically run code using .NET 7, Roslyn and AssemblyLoadContext
Stars: ✭ 83 (+538.46%)
Mutual labels:  roslyn
Avalonia.PropertyGenerator
Avalonia.PropertyGenerator generates the appropriate CLR members for Avalonia property definitions.
Stars: ✭ 20 (+53.85%)
Mutual labels:  roslyn
Platform Compat
Roslyn analyzer that finds usages of APIs that will throw PlatformNotSupportedException on certain platforms.
Stars: ✭ 250 (+1823.08%)
Mutual labels:  roslyn

Introduction

Tool for removing .NET Code Contracts from source code. Currently only C# is supported. I will gladly accept PR with VB support.

.NET 4.7.1 is required to run this application.

Installation

Install-Package CodeContractsRemover

or

Download and un-zip from https://www.nuget.org/api/v2/package/CodeContractsRemover 

Usage

Tool is located at "PROJECT_DIR/packages/CodeContractsRemover.VERSION/tools/".

CodeContractsRemover.exe <Convert|Stats> <directoryPath> [--searchPattern *.cs *.csproj] [--encoding utf-8] [--ignorePattern .svn/ ]

Example

CodeContractsRemover.exe Convert ./myproject

To run using mono on Mac OS X

/Library/Frameworks/Mono.framework/Commands/mono code_contracts_remover.exe Convert ./myproject

To run using mono on Linux

/usr/bin/mono code_contracts_remover.exe Convert ./myproject

Modes

Mode - Convert

  • Converts all Contract.Requires to "if(!x) throw new ArgumentException()" pattern at the beginning of method/property/constructor.
  • Converts all Contract.Ensures to "if(!x) throw new InvalidOperationException()" pattern before each return inside method/property/constructor.
  • Converts all Contract.Assert, Contract.Assume and Contract.Invariant to "if(!x) throw new InvalidOperationException()" pattern.
  • Invokes invariant methods before each return incide method/property/constructor.
  • Preserves all other Contract invocations (including Attributes and Contract classes).
  • Removes CodeContract properties and constants from project files

#### Mode - Remove

  • Removes any Contract invocations.
  • Invariant methods are preserved
  • Attributes and Contract classes are removed
  • Removes CodeContract properties and constants from project files

Mode - Stats

  • Collects statistics about how Contracts are used. Example of result:
[ContractClassFor]                                	  1
[ContractInvariantMethod]                         	  2
Contract.Assert                                   	  1
Contract.Ensures                                  	  6
Contract.Invariant                                	  2
Contract.Requires                                 	  6
Contract.Result                                   	  5

Annotation modes

In Convert mode Jet Brains annotations ([NotNull]) can be added to class members. Jet Brains annotations are added using JetBrains.Annotations NuGet package.

Mode - None

Don't add annotations

Mode - Add

Include 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.

Mode - IncludeIntoBinaries

Annotations 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.

Contributors

  • @ishatalkin
  • @mgaffigan
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].