Open sandboxFocusImprove this doc

LAMA0048: The type receiving introduced members must be partial

Severity Warning
Reported by Metalama.Framework
Message Aspects add members to '<Type>', but it is not marked as 'partial'. Make the type 'partial' to make it possible to reference aspect-generated members from source code.

Cause

When an aspect introduces declarations into a type, such as methods, properties, nested types, or interface implementations, the compiler sees them at build time because Metalama rewrites the code. In the IDE, however, Metalama can't rewrite your source files. Instead, it generates a partial declaration of the type that contains the introduced members, so that IntelliSense can show them and your code can reference them. This requires the type, and any type that contains it, to be declared partial.

Metalama reports LAMA0048 in the IDE when aspects introduce declarations into a type that isn't partial. The build itself still succeeds and the introduced members exist at run time, but you can't reference them from source code, and the IDE doesn't show them. The warning isn't reported during a command-line build.

For instance, if a type aspect has a template method marked with [Introduce] and you apply it to a class declared as internal class Product, the IDE reports LAMA0048 on Product.

This warning is reported only at design time, in the IDE, so it can't be shown in an example.

Resolution

Add the partial modifier to the type, and to its containing types if it's nested. The IDE offers a Make partial code fix for this warning. In the previous example, declare the class as internal partial class Product.

See also