Code Monkey home page Code Monkey logo

virtuosity's Introduction

This is an add-in for Fody

Icon

Change all members to virtual as part of your build.

Introduction to Fody

The nuget package NuGet Status

https://nuget.org/packages/Virtuosity.Fody/

PM> Install-Package Virtuosity.Fody

What it actually does to your assembly

Selects all members that meet the following criteria

  • from non sealed classes
  • non static members
  • non abstract members
  • non private members
  • non virtual members

Change them to virtual

For all (now virtual) members

  • change calls to those members to virtual
  • change new modifiers to override modifiers

Configuration Options

Exclude types with an Attribute

If for some reason you want to skip a specific class you can mark it with a DoNotVirtualizeAttribute.

Since no reference assembly is shipped with Virtuosity. Just add the below class to your assembly. Namespace does not matter.

public class DoNotVirtualizeAttribute : Attribute
{
}

So your class will look like this

[DoNotVirtualize]
public class ClassToSkip
{
    ...
}

Include or exclude namespaces

These config options are access by modifying the Virtuosity node in FodyWeavers.xml

ExcludeNamespaces

A list of namespaces to exclude.

Can not be defined with IncludeNamespaces.

Can take two forms.

As an element with items delimited by a newline.

<Virtuosity>
    <ExcludeNamespaces>
        Foo
        Bar
    </ExcludeNamespaces>
</Virtuosity>

Or as a attribute with items delimited by a pipe |.

<Virtuosity ExcludeNamespaces='Foo|Bar'/>

IncludeNamespaces

A list of namespaces to include.

Can not be defined with ExcludeNamespaces.

Can take two forms.

As an element with items delimited by a newline.

<Virtuosity>
    <IncludeNamespaces>
        Foo
        Bar
    </IncludeNamespaces>
</Virtuosity>

Or as a attribute with items delimited by a pipe |.

<Virtuosity IncludeNamespaces='Foo|Bar'/>

Why is this useful

If you are coding in .net you will have used or heard of one of the following tools

Well all these tools make use of DynamicProxy. DynamicProxy allows for runtime interception of members. The one caveat is that all intercepted members must be virtual. This means that that all the above tools, to some extent, require members to be virtual.

If you forget to mark something as virtual these tools will not work and fail in sometimes very unhelpful ways. So rather than having to remember to use the virtual keyword Virtuosity means members will be virtual by default.

Icon

Russian Doll designed by Simon Child from The Noun Project

virtuosity's People

Contributors

simoncropp avatar

Watchers

James Cloos avatar

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.