public void Execute()
{
var loggingFields = (from field in _type.Fields
where field.IsStatic && string.Equals(field.FieldType.FullName, CatelLoggingClass)
select field).ToList();
if (loggingFields.Count == 0)
{
return;
}
var staticConstructor = _type.GetStaticConstructor();
if (staticConstructor == null)
{
FodyEnvironment.LogWarning($"Cannot weave ILog fields without a static constructor, ignoring type '{_type.FullName}'");
return;
}
var body = staticConstructor.Body;
body.SimplifyMacros();
try
{
UpdateCallsToGetCurrentClassLogger(body);
}
catch (Exception ex)
{
FodyEnvironment.LogWarning($"Failed to update static log definition in '{_type.FullName}', '{ex.Message}'");
}
body.OptimizeMacros();
}