Skip to end of metadata
Go to start of metadata

Fody is an extensible tool for weaving .NET assemblies. For more information about Fody, see its official website

Enabling Catel.Fody

To enable Catel.Fody to weave assemblies, you need to perform the following steps:

Note that the FodyWeavers.xml should be updated automatically when you install the package

Available functionality

Below are the several options available in Catel.Fody:

Disabling weaving for specific types or properties

To disable the weaving of types or properties of a type, decorate it with the NoWeaving attribute as shown in the example below:

[NoWeaving]
public class MyClass : ModelBase
{
    ...
}

Configuring Catel.Fody

Though we recommend to leave the default settings (great for most people), it is possible to configure the weaver. Below is a list of options that can be configured.

PropertyDefault valueDescription
WeavePropertiestrueWeave all regular properties on classes that inherit (directly or indirectly) from Catel.Data.ModelBase into Catel properties.
WeaveExposedPropertiestrueWeave all Catel properties decorated with both the Catel.MVVM.Model attribute and Fody.Expose attribute as automatic mappings.
WeaveArgumentstrueWeave all Argument check attributes into actual argument checks.
WeaveLoggingtrueWeave all calls to LogManager.GetCurrentClassLogger() into LogManager.GetLogger(typeof(classname)).
GenerateXmlSchemasfalseGenerate xml schemas for all classes that inherit (directly or indirectly) from Catel.Data.ModelBase.

To configure an option, modify FodyWeavers.xml by adding the property and value to the Catel element. For example, the example below will disable argument and logging weaving:

<Catel WeaveArguments="false" WeaveLogging="false" />
  • No labels

5 Comments

  1. Is there any way to turn on logging of the Catel.Fody weaver using the weavers.xml file? Specifically something to make the LogInfo/LogWarning to output to stdout when Fody is running during the build?

    1. No. Catel.Fody is hosted by Fody. Fody directly writes error / warning / info to the build like msbuild does. You can only view the logging by modifying the verbosity of the msbuild output in visual studio.

      1. Changing the verbosity level of MSBuild does not give me the desired level of detail for the Fody.Catel weaver.

        I did find out a way to do this.

        I added this line to the Fody.Targets file in the first <PropertyGroup>.

        <FodyMessageImportance>High</FodyMessageImportance>

        With the MSBuild verbosity still at Minimal (Visual Studio default), I can now see all the work that Fody is doing for me.

  2. This was relevant for Catel.Fody 1.91. I've been talking to Simon Cropp about the logging, and this method no longer works as of Fody 1.20