GithubHelp home page GithubHelp logo

cottsak / conventional Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewabest/conventional

0.0 2.0 0.0 4.26 MB

A suite of convention specifications for enforcing type conventions in your codebase

C# 94.97% Shell 5.03%

conventional's Introduction

Conventional Build status

A suite of basic convention tests to run over types to make sure your duckies are all in a row.

To install from NuGet

Install-Package Best.Conventional 

Sample Usage

Standard Syntax

new[] { typeof(MyType), typeof(MyOtherType) }
    .MustConformTo(
        Convention.PropertiesShouldHavePublicGetters.And(
        Convention.PropertiesShouldHavePublicSetters))
    .WithFailureAssertion(Assert.Fail);

Fluent Syntax

new[] { typeof(MyType), typeof(MyOtherType) }
    .MustConformTo(Convention.PropertiesShouldHavePublicGetters)
    .AndMustConformTo(Convention.PropertiesShouldHavePublicSetters)
    .WithFailureAssertion(Assert.Fail);

Or Mix It Up!

new[] { typeof(MyType), typeof(MyOtherType) }
    .MustConformTo(
        Convention.PropertiesShouldHavePublicGetters.And(
        Convention.PropertiesShouldHavePublicSetters))
    .AndMustConformTo(Convention.MustHaveADefaultConstructor)
    .WithFailureAssertion(Assert.Fail);

Supplied Conventions

  • Properties must have public getters
  • Properties must have public setters
  • Name must start with
  • Name must end with
  • Must live in namespace
  • Must have a default constructor
  • Must have appropriate constructors
  • Must have attribute
  • Must not take a dependency on
  • Requires a corresponding implementation of (T)
  • Void methods must not be async
  • Enumerable properties must be eager loaded
  • Collection properties must be immutable
  • All properties must be immutable

Conventional.Cecil

A suite of Mono.Cecil-based convention tests, for when standard reflection just wont cut it.

To install from NuGet

Install-Package Best.Conventional.Cecil

Sample Usage

new[] { myAssembly }
    .WhereTypes(x => x) // Insert funky type narrowing predicate of choice here
    .MustConformTo(CecilConvention.MustNotUseDateTimeNow)
    .WithFailureAssertion(Assert.Fail);

Supplied Conventions

  • Must not use DateTime.Now
  • Must not use DateTimeOffset.Now
  • Exceptions thrown must be derived from specified type
  • Must instantiate properties of specified type in default constructor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.