Open sandboxFocusImprove this doc

LAMA0879: A declared durable type name matches no type

Severity Warning
Reported by Metalama.Framework (Roslyn analyzer)
Message The name '<TypeName>', declared in <ItemName>, matches no type in this compilation. A generic type must be written with its arity, as in System.Collections.Generic.List`1.

Cause

The analyzer that verifies the [Durable] contract needs to know whether a type is safe to hold across compilations. For a type that your project doesn't own, you can declare the answer in your project file with the MetalamaDurableType item, for a type that is durable, or the MetalamaNonDurableType item, for a type that isn't.

Metalama reports LAMA0879 at the end of the compilation when the name of such an item can't be resolved to a type of the compilation. Without this warning, a mistyped name would be a declaration that silently never applies. The name is compared with the full metadata name of the types, which means:

  • The name is the full name of the type, including its namespace.
  • A nested type is separated from its container by +, not ..
  • A generic type is written with its arity, with a backtick followed by the number of type parameters, as in System.Collections.Generic.List`1.
  • The type must exist in the compilation, which means that its assembly must be referenced by the project.

In the message, <TypeName> is the name that couldn't be resolved and <ItemName> is the MSBuild item that declares it, MetalamaDurableType or MetalamaNonDurableType. The warning has no source location, because the name comes from the project file.

This diagnostic comes from MSBuild configuration and is reported by a Roslyn analyzer, which snapshot tests don't run, so it can't be shown in an example.

Resolution

  1. Find the item named in the message in your project file or in a Directory.Build.props file.
  2. Fix the name. Write the full name of the type with its namespace, add the arity of a generic type (List`1, not List), and separate nested types with +.
  3. If the type comes from a package, check that the project references it. Otherwise, remove the item.

For instance, the following declaration marks a type of the .NET library as durable:

<ItemGroup>
    <MetalamaDurableType Include="System.Text.RegularExpressions.Regex" />
</ItemGroup>

See also