Open sandboxFocusImprove this doc

LAMA0306: A suppression defined by an aspect isn't registered in the IDE yet

Severity Warning
Reported by Metalama.Framework
Message An aspect suppressed the diagnostic '<Id>' on '<Symbol>', but this suppression is not yet registered in the current IDE session due to an IDE limitation. Restart your IDE to apply the suppression.

Cause

An aspect can suppress a diagnostic, for instance a C# compiler warning, by defining a SuppressionDefinition and calling builder.Diagnostics.Suppress. At design time, the IDE asks Metalama's diagnostic suppressor for the list of the diagnostic IDs it can suppress, and it asks only once, when the suppressor is loaded. Metalama discovers the suppressions defined in compile-time code only when it compiles this code. It then records them in the userDiagnostics.json file of your user profile, and the IDE reads this file the next time it loads Metalama.

When an aspect suppresses a diagnostic whose ID wasn't in the list of suppressions when the IDE session started, the IDE doesn't let Metalama suppress it, so the original diagnostic stays visible. Metalama reports LAMA0306 on the declaration where the suppression applies, to explain why. In the message, <Id> is the ID of the suppressed diagnostic and <Symbol> is the declaration. This typically happens when you've just added a suppression to an aspect, or just added a reference to a new aspect library, during the current IDE session.

The command-line build isn't affected: it applies the suppression.

This diagnostic depends on the state of the IDE session, so it can't be shown in an example.

Resolution

  1. Restart the IDE. In Visual Studio, close all instances and reopen the solution. In Rider, close and reopen Rider. In Visual Studio Code, run the Developer: Reload Window command.
  2. After the restart, the IDE applies the suppression: both the suppressed diagnostic and LAMA0306 disappear.
  3. If LAMA0306 persists after the restart, check that Metalama could register the suppression. Open userDiagnostics.json, located in the %appdata%\Metalama directory on Windows and in the ~/.metalama directory on Linux and macOS, and verify that its Suppressions list contains the ID of the suppressed diagnostic. If it doesn't, make sure that the file and its directory are writable, then reopen the solution, wait for Metalama to analyze it, and restart the IDE again. To investigate further, enable logging as described in Enabling logging.

See also