Metalama 2024.0 Generally Available: .NET 8 and C# 12

by Gael Fraiteur on 02 Jan 2024

We’re thrilled to announce the general availability of Metalama 2024.0! This release primarily focuses on providing support for C# 12, along with a few additional tasks remaining from previous releases when we made the Metalama source code available.

Note that we are simultaneously releasing PostSharp 2024.0.

Support for C# 12

We’ve merged Roslyn 4.8 into Metalama.Compiler, our open-source branch of Roslyn adding code transformers.

Next, we updated and tested Metalama.Framework to support the following additional C# features:

  • Default lambda parameters,
  • Inline arrays in run-time code,
  • nameof: Access to instance members from a static context,
  • Primary constructors,
  • Type aliases,
  • Collection expressions (also known as collection literals) like [1,2,..array],
  • AppendParameter advice (utilized in dependency injection scenarios) in primary constructors,
  • Primary constructor parameters in initializer expressions.

Multi C# version support

Metalama 2024.0 proudly stands as our first version supporting multiple versions of C#.

  • Metalama uses different C# code generation patterns based on the C# version of the current project. We support versions 10, 11, and 12, the latest version that came with .NET 8.
  • Metalama identifies the version used by each T# template and will report an error if a template is used in a project targeting a lower version of C# than required. The new MSBuild property MetalamaTemplateLanguageVersion restricts the version of C# that can be used in templates. Define this property to prevent the accidental use of a higher version of C# than intended.
  • At present, there’s no way for a template to conditionally generate code patterns according to the C# version of the target project.

Other improvements

  • Deterministic build is now implemented for all Metalama assemblies. This feature allows users to verify that the released binaries were indeed built from our source code. The only differences between the official assemblies and your own builds should be the strong-name and Authenticode signatures. Please note that building Metalama from source code requires a source subscription, available for an additional fee.
  • Symbol packages: We’ve now published symbol packages for all Metalama NuGet packages, enabling source code debugging via SourceLink.
  • Warnings and errors deduplication. Currently, we do not support this in the user API.
  • Licensing: Aspect inheritance is now allowed for all license types.

Breaking changes

In the RefKind enum, In and RefReadOnly are no longer synonymous.

In Progress

We’re currently working on the following projects, but they are not yet stable:

Changelogs

For a more detailed list of changes and bug fixes, please refer to the changelogs:

Conclusion

Metalama 2024.0 is now stable and ready for you! You can safely use all the new features released by Microsoft seven weeks ago. We look forward to seeing the amazing aspects you’ll create! Please join our Slack community and show off!

P.S. We are partnering with SlashData. Please participate in the Developer Nation Survey if you haven’t done it.