[Home](../) › [Blog](../blog) › Metalama Status Update, July-August 2024

# Metalama Status Update, July-August 2024

> On the last day of July, we announced the GA of Metalama 2024.2, shipping some long-awaited features. In August, we mostly focused on bug fixes and minor features, all released in the 2024.2 branch. The most significant addition is the ability to decouple aspects from attributes.

Published: 2024-08-30 · Author: Gaël Fraiteur · Canonical: https://postsharp.net/blog/metalama-status-update-2024-08

I hope those of you in the Northern Hemisphere had a wonderful and restful summer! Despite the annual slowdown, our development team didn't stay idle. On the last day of July, we announced the GA of Metalama 2024.2, shipping some long-awaited features. In August, we mostly focused on bug fixes and minor features, all released in the 2024.2 branch.

## Metalama 2024.2 GA

We released the [first stable build of Metalama 2024.2](https://postsharp.net/blog/metalama-2024-2-ga) on July 29th. This release introduces the most-requested feature: the ability to generate new classes (previously, you could only introduce new members into existing classes). We also added new ready-made aspects. Here's a summary of the new features:

* New code generation abilities:
    * [Generate new types](https://doc.metalama.net/conceptual/aspects/advising/introducing-types)
    * [Introduce](https://doc.metalama.net/conceptual/aspects/advising/introducing-members) or [override](https://doc.metalama.net/conceptual/aspects/advising/overriding-constructors) constructors
    * [Switch statement builder](https://doc.metalama.net/api/metalama-framework-code-syntaxbuilders-switchstatementbuilder)
    * Lambda statements and anonymous methods in T# templates
* New open-source, ready-made aspects:
   * [Observable](https://doc.metalama.net/patterns/observability) for `INotifyPropertyChanged`
   * [Command](https://doc.metalama.net/patterns/wpf/command) and [DependencyProperty](https://doc.metalama.net/patterns/wpf/dependency-property) for WPF
   * [Immutable](https://doc.metalama.net/patterns/immutability)
* [Performance improvements](https://postsharp.net/blog/metalama-performance)
* Dozens of [smaller enhancements](https://doc.metalama.net/conceptual/release-notes/release-notes-2024-2)

After the GA, we primarily focused on fixing bugs, particularly in the design-time (i.e., editing) experience. A total of 32 bugs were fixed after the GA.

See all [changelogs](https://github.com/orgs/metalama/discussions/categories/changelog) for details.

## Post-release improvements in Metalama 2024.2

In addition to bug fixes, we also added a few minor features in Metalama 2024.2:

### Decoupling aspects from attributes

It's now easier to separate your aspect logic from the custom attribute. Several approaches are supported and [documented here](https://doc.metalama.net/conceptual/aspects/decoupling-from-attributes). This is made possible by the following new APIs:

* Most interfaces derived from `IDeclaration` (e.g., `IField`, `IMethod`, ...) now have a `GetRef()` method returning a strongly-typed `IRef<T>`.
* `IRef<T>` now has an `As<TOut>()` method to up-type the reference.
* `ExpressionFactory` enhancements: `Null` and `Default` methods.
* We added a method `IAttributeCollection.GetConstructedAttributesOfType<T>(): IEnumerable<T>`.
* We added extension methods `ICompilation.GetDeclarationsWithAttribute()`.
* We added extension methods `IAspectReceiver<ICompilation>.SelectDeclarationsWithAttribute()` and `IValidatorReceiver<ICompilation>.SelectDeclarationsWithAttribute()` for use in fabrics.
* We added extension methods `IAttribute.GetArgumentValue()` and `IAttribute.GetArgumentValue()` to easily get arguments by name.
* The `TypedConstant` struct now implements `IEquatable<TypedConstant>`.
* When a `TypedConstant` represents an array, the `Value` property now returns the "user" array, e.g., `int[]` or `object[]`, instead of an `ImmutableArray<TypedConstant>`.

### Testing experience

* New `TestContext.WithExecutionContext()` method added, allowing the use of classes like `ExpressionFactory` in compile-time unit tests.
* You can now test your aspects in scenarios other than compile-time generation by specifying the `@TestScenario` test directive. The following additional scenarios are available: code fix, live template, and design-time preview.

## Articles

This summer, we published 6 general .NET articles.

<div class="article-thumbnails">
 <a href="https://postsharp.net/blog/aspnet-caching">
      <img src="https://postsharp.net/assets/images/2024/2024-08-aspnet-caching/aspnet-caching-1e4510965d.svg" alt="Five Ways To Add Caching To Your ASP.NET App"/>
  </a>
 <a href="https://postsharp.net/blog/singleton-pattern">
      <img src="https://postsharp.net/assets/images/2024/2024-08-singleton/singleton-dark-280435b4e1.svg" alt="The Singleton Pattern in C# Today Is Not Your Dad's One!"/>
  </a>
 <a href="https://postsharp.net/blog/memento">
      <img src="https://postsharp.net/assets/images/2024/2024-07-memento/memento-light-ed245f11a8.svg" alt="The Memento Design Pattern in C#, Practically With Examples [2024]"/>
  </a>
  <a href="https://postsharp.net/blog/serilog-aspnetcore">
      <img src="https://postsharp.net/assets/images/2024/2024-07-serilog-aspnet/logging-6b28ea2786.svg" alt="Adding Serilog to ASP.NET Core: a practical guide"/>
  </a>

  <a href="https://postsharp.net/blog/aspire-caching-metalama">
      <img src="https://postsharp.net/assets/images/2024/2024-07-aspire/aspire-caching-light-a8d06cd5bf.svg" alt="Simplify Your .NET Aspire Caching With Metalama"/>
  </a>

  <a href="https://postsharp.net/blog/memorycache">
      <img src="https://postsharp.net/assets/images/2024/2024-07-memorycache/memorycache-7b22629d18.min.svg" alt="MemoryCache in C#: A Practical Guide"/>
  </a>

</div>

## Roadmap

September is usually the time when Microsoft releases the first RC of their new .NET stack. We plan to focus on .NET 9 and C# 13 as soon as this happens, updating both PostSharp and Metalama in what will become the 2025.0 versions. Our objective is to publish RCs of both products soon after the GA of the new .NET stack, traditionally in November. We expect these new versions to be generally available in the very first days of 2025. The feature that will likely require most of our attention is the Roslyn interceptors.

You might experience issues if you update your projects to .NET 9 without updating to Metalama 2025.0, so we suggest you pin your .NET SDK version in `global.json` and limit `rollforward` to `minor`.

## Conclusion

We released Metalama 2024.2, the most anticipated release with support for type introductions, on July 29th. In August, we focused on bug fixes. The design-time experience is much more comfortable than before, and we encourage everyone to update to the newest build.

Stay tuned for news on Metalama 2025.0 starting in September.

Happy meta-programming with Metalama!

-gael

---

## Site navigation

- Index of the whole site: [llms.txt](../llms.txt)

