The primary objective of Metalama 2024.1 is to enhance the user interface by improving Visual Studio tooling and introducing a new license activation UI. You can now override constructors.
User interface
Unification of Visual Studio Tools for Metalama
Previously, Metalama and PostSharp each had their own Visual Studio extension with unique features and user experiences. In Metalama 2024.1, we merged these two extensions into one, unifying the development experience. Whether you're using Metalama, PostSharp, or both, install a single extension named Visual Studio Tools for Metalama, or Metalama + PostSharp.
Aspect Explorer
The Aspect Explorer tool window, previously available only to PostSharp users, now also supports Metalama.
The Aspect Explorer consists of three panels. The first panel displays all aspect classes available in the solution. When you click on an aspect class in this panel, the second panel displays the list of declarations affected by this aspect class. When you click on one of these declarations, the third panel displays the list of transformations applied by this aspect to the selected declaration.
Double-click any declaration to open it in the code editor.

Learning Hub
The Learning Hub displays articles and tutorials, prioritizing them based on your learning objectives. For instance, if you're interested in logging, it displays tutorials relevant to logging, sorted in increasing order of complexity.
ARM64 support
Visual Studio Tools for Metalama works on ARM64 devices.
Licensing UI
When using Metalama for the first time, a UI guides you through registering your license key or choosing between the trial and the free edition. You can also subscribe to a newsletter and the Metalama email course.
Toast notifications for unhandled exceptions are now available.
Overriding constructors
You can now override instance constructors from the aspect's BuildAspect method by calling the AdviserExtensions.Override method and passing an IConstructor.
This works for both standard constructors and primary constructors. If you override the primary constructor, it's transparently expanded into a standard constructor.
For details, see Overriding constructors.
Other improvements
- Numeric contracts now generate idiomatic code.
- Metalama 2024.1 processes aspects approximately 55% faster than 2024.0. However, the fixed cost of using Metalama instead of the vanilla C# compiler hasn't improved. For details, see this analysis.
Breaking changes
- Initializers are now all executed before constructor parameter contracts. Previously, initializers and contracts on constructors could be interleaved.
- The ordering of contracts within the same method has been fixed.
- Contracts are now ineligible on unimplemented partial methods.
- In TypeFactory, the generic methods
public static T ToNullableType<T>( this T type ) where T : ITypeandpublic static T ToNonNullableType<T>( this T type ) where T : ITypehave been replaced by a set of non-generic overloads (see ToNullableType and ToNonNullableType), taking into account the fact that the nullable type of an ITypeParameter isn't an ITypeParameter if the type parameter has astructconstraint. - The UnderlyingType property, when the INamedType represents a
Nullable<T>(i.e., a nullable value type), no longer returnsTbutNullable<T>. This behavior is now consistent with other generic types but no longer consistent with nullable reference types.