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.
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() { }
}
- Install the NuGet package:
PM> Install-Package PostSharp.Community.Virtuosity
- Get a free PostSharp Community license at https://www.postsharp.net/essentials
- When you compile for the first time, you'll be asked to enter the license key.
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.
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.
Released under the MIT license.
- Copyright by Simon Cropp, PostSharp Technologies, and other contributors.
- Icon by BomSymbols, https://www.iconfinder.com/korawan_m