| Severity | Warning |
| Reported by | Metalama.Framework |
| Message | Could not resolve the declaration with id '<DeclarationId>' when looking for template attributes. This can happen when several referenced assemblies define a type that is part of the declaration signature. |
Cause
When Metalama loads an aspect or a fabric, it reads the template attributes, such as [Template], of each template member. It identifies each member by a serialized declaration id, <DeclarationId> in the message, which includes the types of the member signature, and resolves this id in the current compilation.
Metalama reports LAMA0268 when this id can't be resolved. This typically happens when the project references several assemblies that define a type with the same full name, and this type is part of the signature of the template member, for instance the type of a parameter. Metalama then ignores the template member, so advice that uses it may fail later.
This warning depends on the assembly references of the project, so it can't be shown in an example.
Resolution
- Find the template member from the id in the message: the id starts with a letter for the member kind (
M:for a method,P:for a property), followed by the full name of the member and the types of its parameters. - Check whether one of the types of its signature is defined in several assemblies referenced by the project, for instance two versions of the same library, or a library that embeds a copy of another one. Remove the duplicate reference, or align the package versions.
- If you're the author of the aspect, avoid such types in the template signature.