MONFY01: Type is not compatible with Monify
August 22, 2025 ยท View on GitHub
| Type Name | MONFY01_AttributeAnalyzer |
| Diagnostic Id | MONFY01 |
| Category | Usage |
| Severity | Warning |
| Is Enabled By Default | Yes |
Cause
A type declaration upon which the Monify attribute is placed is not a class, record or struct.
Rule Description
A violation of this rule occurs when the Monify attribute is placed on a type declaration that is not a class, record or struct. This occurs most commonly when placed upon a interface declaration.
How to Fix Violations
To fix a violation of this rule, determine if the declaration type is correct for the intended usage. If the type is correct, remove the Monify attribute from the declaration, otherwise change the declaration for the type to a class, record or struct.
For example:
[Monify<byte>]
public partial interface IAge
{
bool IsAdult { get; }
}
How to Suppress Violations
It is not recommended to suppress the rule. Instead, it is suggested that the usage of the Monify attribute be reevaluated.
If suppression is desired, one of the following approaches can be used:
#pragma warning disable MONFY01 // Type is not compatible with Monify
[Monify<byte>]
public partial interface IAge
{
bool IsAdult { get; }
}
#pragma warning restore MONFY01 // Type is not compatible with Monify
or alternatively:
[Monify<byte>]
[SuppressMessage("Design", "MONFY01:Type is not compatible with Monify", Justification = "Explanation for suppression")]
public partial interface IAge
{
bool IsAdult { get; }
}
How to Disable MONFY01
It is not recommended to disable the rule, as this may result in some confusion if the expected equality behavior is not observed.
# Disable MONFY01: Type is not compatible with Monify
[*.cs]
dotnet_diagnostic.MONFY01.severity = none