Metalama 2024.1 Now Generally Available: Unified Visual Studio Extension, Overriding Constructors, and More

by Gael Fraiteur on 17 Apr 2024

We’re thrilled to unveil the general availability of Metalama 2024.1. Our latest release focuses on enhancing the user interface, with special attention to Visual Studio tooling and the introduction of an intuitive license activation UI. We’ve also made it possible to override constructors.

Note that this release has special update instructions.

Unification of Visual Studio Tools for Metalama and PostSharp

In the past, Metalama and PostSharp each had their respective Visual Studio extensions, each boasting a unique set of features and user experiences. In Metalama 2024.1, we’ve combined these two extensions into one, creating a unified development experience. Whether you’re using Metalama, PostSharp, or both, you’ll need to install just one extension: the Visual Studio Tools for Metalama and PostSharp, or, in short, Metalama + PostSharp.

Additionally to updating your NuGet packages, updating the Visual Studio extension for Metalama 2024.1 requires a manual step:

  1. Uninstall the deprecated Metalama Tools for Visual Studio.
  2. Install Visual Studio Tools for Metalama and PostSharp.

Aspect Explorer

The Aspect Explorer tool window, previously exclusive to PostSharp users, now also supports Metalama.

The Aspect Explorer features three panels. The first panel displays all available aspect classes in the solution. Click on an aspect class, and the second panel shows the list of declarations affected by this aspect class. Select one of these declarations, and the third panel lists the transformations applied by this aspect to the selected declaration.

You can double-click any declaration to open it in the code editor.

Learning Hub

The Learning Hub presents articles and tutorials, prioritizing them based on your learning goals. For example, if you’re interested in logging, the Learning Hub will first show you tutorials relevant to logging. These tutorials are sorted in ascending order of complexity.

ARM64 Support

The Visual Studio Tools for Metalama and PostSharp perform seamlessly on an ARM64 device.

Licensing UI

On your first use of Metalama, a user-friendly UI will guide you through registering your license key or choosing between the trial and the free edition. You’ll also have the option to subscribe to our newsletter and the Metalama email course.

We’ve also introduced toast notifications for unhandled exceptions.

Overriding constructors

You can now override instance constructors from the aspect’s BuildAspect method by calling the IAdviceFactory.Override method and passing an IConstructor.

This feature works for both standard constructors and primary constructors. If you attempt to override the primary constructor, it will be transparently expanded into a standard constructor.

Other improvements

  • Numeric contracts now generate idiomatic code.

Breaking Changes

  • All initializers are now executed before constructor parameter contracts. Previously, initializers and contracts on constructors could be interleaved.
  • The order of contracts within the same method has been fixed.
  • Contracts are now ineligible for unimplemented partial methods.
  • In TypeFactory, the generic methods public static T ToNullableType<T>( this T type ) where T : IType and public static T ToNonNullableType<T>( this T type ) where T : IType have been replaced by a set of non-generic overloads. This change takes into account that the nullable type of an ITypeParameter is not an ITypeParameter if the type parameter has a struct constraint.
  • The INamedType.UnderlyingType property, when the INamedType represents a Nullable<T> (i.e., a nullable value type) no longer returns T but Nullable<T>. This behavior is now consistent with other generic types but no longer consistent with nullable reference types.

Changelogs

For a low-level list of fixed bugs, please refer to the changelogs of indivual builds leading to this release: 2024.1.12, 2024.1.11-rc, 2024.1.10-rc, 2024.1.9-rc, 2024.1.8-preview, 2024.1.7-preview, 2024.1.6-preview, 2024.1.5-preview, 2024.1.4-preview, 2024.1.3-preview, 2024.1.2-preview and 2024.1.1-preview.

Roadmap

We’re already hard at work on Metalama 2024.2. The main focus of the next release will be the ability to introduce new types, as the current version only allows adding members to existing types. We’re also improving the fabrics API, especially for validation, from a performance and usability standpoint. We’re also completing the release of the INotifyPropertyChanged and XAML aspects that have been in preview for several months.

Summary

Metalama 2024.1 is here, with a unified Visual Studio extension, an improved licensing UI, and the ability to override constructors. Discover the full potential of Metalama today, and don’t forget to give us feedback on Slack.