This is an add-in for Fody
Adds an empty constructor to classes even if you have a non-empty one defined.
See also Fody usage.
Install the EmptyConstructor.Fody NuGet package and update the Fody NuGet package:
PM> Install-Package EmptyConstructor.Fody
PM> Update-Package Fody
The Update-Package Fody
is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.
Add <EmptyConstructor/>
to FodyWeavers.xml
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
<EmptyConstructor/>
</Weavers>
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
{
...
}
These config options are access by modifying the EmptyConstructor
node in FodyWeavers.xml
The visibility to use when injecting constructors.
Can not be defined with Visibility
.
Allowed values: public
or family
(aka protected
)
Defaults to public
.
For example
<EmptyConstructor Visibility='family'/>
Optionally the visibility of already existing constructors can be increased.
If this feature is enabled, the visibility of empty-constructors of non-abstract types will be increased to the same visibility as defined by the Visibility
configuration (see above).
For example
<EmptyConstructor MakeExistingEmptyConstructorsVisible='True'/>
Will ensure all constructors on non-abstract types will be public
.
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.
<EmptyConstructor>
<ExcludeNamespaces>
Foo
Bar
</ExcludeNamespaces>
</EmptyConstructor>
Or as a attribute with items delimited by a pipe |
.
<EmptyConstructor ExcludeNamespaces='Foo|Bar'/>
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.
<EmptyConstructor>
<IncludeNamespaces>
Foo
Bar
</IncludeNamespaces>
</EmptyConstructor>
Or as a attribute with items delimited by a pipe |
.
<EmptyConstructor IncludeNamespaces='Foo|Bar'/>
Icon courtesy of The Noun Project