Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Latest commit

 

History

History
49 lines (38 loc) · 1.94 KB

README.md

File metadata and controls

49 lines (38 loc) · 1.94 KB

  PostSharp.Community.Virtuosity

Allows you to make all target methods virtual without adding the virtual keyword to every one of them.

This is an add-in for PostSharp. It modifies your assembly during compilation by using IL weaving.

CI badge

Example

Your code:

[assembly: Virtual]
class A 
{
  public void M1() { }
  protected void M2() { }
  private void M3() { }
}

What gets compiled:

class A 
{
  public virtual void M1() { }
  protected virtual void M2() { }
  private void M3() { }
}

Installation

  1. Install the NuGet package: PM> Install-Package PostSharp.Community.Virtuosity
  2. Get a free PostSharp Community license at https://www.postsharp.net/essentials
  3. When you compile for the first time, you'll be asked to enter the license key.

How to use

Add [Virtual] to the classes, namespaces or assemblies where you want it to apply. We call this multicasting.

By annotating a class with [Virtual], you make all methods in that class virtual or override. By annotating the assembly, you make ALL methods virtual. As something in between, you can use the various properties of the VirtualAttribute to specify what kinds of methods of what classes should be made virtual.

For more details, read Details and examples.

Limitations

Delegates: Delegates to a [Virtual] method will always resolve to the method itself, not to the overwritten method in a derived class. That is, delegate creation will ignore the new virtual nature of the method.

Copyright notices

Released under the MIT license.