Allows you to make all target methods virtual without adding the virtual keyword to every one of them.
This is a Metalama aspect. It modifies your code during compilation by using source weaving.
Your code:
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:
dotnet add package Metalama.Open.Virtuosity
. -
Apply the aspect to the project by adding the following attribute to some C# file:
[assembly: Metalama.Open.Virtuosity.VirtuosityAspect]
By annotating an assembly with [VirtuosityAspect]
, you make all methods virtual
(except those that can't be virtual
, like static
and private
methods and methods on struct
s).
For more details, see Details.