Metalama 2023.2 is Generally Available

by Gael Fraiteur on 07 Aug 2023

Metalama 2023.2 is now generally available. This latest release prioritizes bug fixes and integrates minor enhancements in response to community feedback.

Enhancements

  • IAdviceFactory.ImplementInterface: The members created by IAdviceFactory.ImplementInterface are now exposed via the IImplementInterfaceAdviceResult interface.
  • An extension method, IType.ToTypeOfExpression(), has been added, returning an IExpression representing the typeof for the given type.
  • Our test framework is now compatible with xUnit 2.5.0.
  • The [Inheritable] annotation can be added to type fabrics, which prompts the type fabric invocation not only for the target type but also for all derived types.
  • In the code model, we’ve introduced APIs to filter collections by unbound generic types:
    • ConversionKind.TypeDefinition has been added to match type definitions while ignoring any generic argument.
    • IAttributeCollection.OfAttributeType( INamedType type, ConversionKind conversionKind ) has been introduced.
    • IAttributeCollection.Any( INamedType type, ConversionKind conversionKind ) has been added.
    • IAttributeCollection.Any( Type type, ConversionKind conversionKind ) has been added.
    • INamedTypeCollection.OfTypeDefinition( INamedType typeDefinition ) has been added.

Breaking changes

  • The interpretation of ConversionKind.Default, utilized as a default parameter value in the IType.Is(IType, ConversionKind) API, has been adjusted to more accurately reflect the documented behavior of the C# is operator. This impacts any method accepting ConversionKind, whether explicitly specified or not, such as TypeExtensions.Is.

Including .NET SDK Analyzers

In June, our users encountered difficulties when upgrading Visual Studio to version 17.6. One such issue arose from the analyzers in the new version of .NET SDK, which were tied to a Roslyn version more recent than what Metalama supported. Users had to amend their global.json to pin .NET SDK to a version compatible with Metalama. Though the hiccup affected a small number of users, it fell short of our quality standards. We are committed to ensuring you can install Visual Studio and .NET SDK without worrying about Metalama compatibility.

To avert similar future issues, we’ve chosen to incorporate .NET SDK analyzers within our Metalama.Compiler package. If your project employs analyzers designed for a newer Roslyn version than what Metalama.Compiler currently supports, we will default to the version contained in our package. This measure ensures your build won’t fail after an update of Visual Studio or .NET SDK. However, a warning will be issued under these circumstances to alert you that you’re not running the expected version of analyzers.

Bug Fixes

Metalama 2023.2 includes a total of 32 bug fixes. For a detailed report, please consult our incremental changelog:

What’s Next?

When we’re not on vacation, our efforts are directed towards developing Metalama 2023.3. Unlike 2023.1 and 2023.2, which focused primarily on bug fixes, 2023.3’s main objective is to port the contracts and caching patterns from PostSharp to Metalama, and lay the groundwork for porting the NotifyPropertyChanged aspect. We’ve already released a preliminary preview addressing 30 work items, including major enhancements to the architecture validation pillar, aspect debugging experience, and aspect error reporting. Future releases will enable one template to call another and an aspect to directly use the Roslyn API for project analysis or modification.

Post-summer, as Microsoft begins to roll out the first Release Candidates of .NET 8.0, our attention will shift towards adapting both Metalama and PostSharp to the upgraded .NET stack.

Conclusion

Similar to 2023.1, the primary aim of Metalama 2023.2 is to fix bugs and introduce a few minor improvements, without introducing any major features. We highly recommend this update. As a note, 2023.0 is no longer supported as we maintain and develop only three versions concurrently.

Enjoy your meta-programming journey!