| Severity | Hidden |
| Reported by | Metalama.Framework |
| Message | <Id>: <Message> — Diagnostic '<Id>' is new and could not be registered in the current session due to an IDE limitation. Please restart your IDE to see it under its correct ID. |
Cause
Aspects, fabrics, and aspect libraries can define their own diagnostics with DiagnosticDefinition. At design time, the IDE asks each analyzer for the list of the diagnostic IDs it can report, and it asks only once, when the analyzer is loaded. Metalama knows its built-in diagnostics in advance, but it discovers the diagnostics 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 reports a hidden diagnostic whose ID wasn't in userDiagnostics.json when the IDE session started, Metalama can't report it under its own ID. It reports LAMA0304 instead, at the same location. In the message, <Id> is the original ID of the diagnostic and <Message> is its original message. This typically happens when you've just added a diagnostic to an aspect, or just added a reference to a new aspect library, during the current IDE session.
A hidden diagnostic isn't shown in the Error List, so you typically notice LAMA0304 only through the code fixes it carries.
While the diagnostic is wrapped, IDE settings that target its original ID, like #pragma warning disable, NoWarn, or a severity in .editorconfig, don't apply to it, because the IDE sees the ID LAMA0304. Code fixes attached to the diagnostic are still offered. The command-line build isn't affected: it always reports the diagnostic under its original ID.
This diagnostic depends on the state of the IDE session, so it can't be shown in an example.
Resolution
- 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.
- After the restart, the IDE reports the diagnostic under its original ID, and LAMA0304 disappears.
- If LAMA0304 persists after the restart, check that Metalama could register the diagnostic. Open
userDiagnostics.json, located in the%appdata%\Metalamadirectory on Windows and in the~/.metalamadirectory on Linux and macOS, and verify that it contains the original ID. 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.