Quantcast
Channel: PostSharp Blog
Viewing all 419 articles
Browse latest View live

Metalama Status Update (October 2022)

$
0
0

We spent most of October fixing bugs – a whopping 85 in total, published in 10 builds, just this month. We also improved performance and filled minor API gaps. This time, we did not have to perform any significant refactoring and, as you can judge from the numbers, our pace was greatly accelerated.

Bug fixing

We successfully completed brute force testing on NopCommerce, a large open source project with a .NET codebase. It uncovered a dozen of defects that are now fixed, and provided a large-scale use case for performance testing and tuning.

There are still a few severe bugs and a few challenges in the design-time (code editing) experience due to random, hard-to-reproduce situations.

On a side note, we have been working on PostSharp 6.11, which will support .NET 7.0 and C# 11. It took some resources away from Metalama, but it shows our complete commitment to support and maintain PostSharp in the upcoming years.

PostSharp migration

We started the work to streamline the migration of projects from PostSharp to Metalama and have published the PostSharp API Annotated for Migration to Metalama. This work is not completed: we still want to write a conceptual documentation for the migration, and a Metalama replacement for PostSharp aspect multicasting so that customers who have dozens of usages of multicast attributes do not need to rewrite every single one of them.

It is still not recommended to migrate your project from PostSharp to Metalama unless you have some spare time, want to help us, or simply want to have fun – because Metalama is fun!

New features

This is a pretty short list, which I think is good news:

  • Ability to add compile-time packages: you can now use any .NET Standard 2.0 project at compile time by including them as a MetalamaCompileTimePackage item in your csproj.
  • Support for packages.config: you can now use Metalama with legacy projects as long as the target framework is compatible with .NET Standard 2.0.
  • IAdviceFactory.Override(IMethod) now works with property and event accessors.

What’s next

In November, we will continue fixing bugs like crazy, filling the remaining gaps, and easing the migration from PostSharp. Our objective is to have one or two RCs before Christmas, which I think is realistic.

We will also post a preview of PostSharp 6.11.

We hope to welcome new beta users on our open Slack community– the best way to get quick feedback in real time. You can also submit bugs and feature requests from different channels. Your feedback is greatly appreciated and is guaranteed to have a large impact on the final product.

Happy meta-programming with Metalama!

-gael


Announcing PostSharp 6.11 RC: Support for .NET 7.0 and C# 11

$
0
0

We’re happy to announce that PostSharp 6.11 RC is now available for download as a preview release on NuGet. You can also download PostSharp Tools for Visual Studio 2022 from our website.

The two points of PostSharp 6.11 are a platform update and Metalama compatibility.

Platform update

PostSharp 6.11 RC supports .NET 7.0, C# 11 and Visual Studio 2022.4.

PostSharp 6.10 remains our current long-term supported (LTS) release, as PostSharp 6.11 relies on the non-LST .NET 7.0.

Side-by-side Metalama compatibility

As many of you may already know, we have been working hard on Metalama during the last two years. Metalama is our next-generation meta-programming platform, entirely based on Roslyn instead of MSIL rewriting. We have done great progress with Metalama and should announce an RC soon.

As we expect teams to use both PostSharp and Metalama during a transition period, we have prepared PostSharp 6.11 Tools for Visual Studio to be side-by-side compatible with Metalama. Concretely, PostSharp Tools for Visual Studio will no longer offer, in the refactoring menu and elsewhere, the possibility to add an aspect to a project if the package that implements this aspect is not already added to that project. This feature was built even before NuGet existed, was still useful when NuGet went though infancy, but it seems now redundant.

Please note that it is not recommended to use PostSharp and Metalama in the same project. By side-by-side compatibility, we mean different projects.

Summary

If you are planning to update your projects to .NET 6.7 soon, or if you want to give Metalama a try, it’s a good idea to try to update to PostSharp 6.11 and report any problem via our support forum so we can strike when the iron is hot.

Happy PostSharping!

-gael

Metalama Status Update (November 2022)

$
0
0

It has been another month of bug fixing and polishing in Metalama and I’m glad to announce that, at the time of writing, we have zero severe bug in our backlog! We also progressed with PostSharp migration assistance, .NET 7.0 / C# 11 support, LinqPad support, and we even integrate with CodeLens!

Zero severe bug

We have fixed 55 bugs in November and have reached an important milestone: zero severe bug. We define a severe bug as a bug that prevents you from editing or building your project without changing your business code (as opposed to the aspect code). Of course it does not mean that no customer experiences any bug any more, but this is a big step forward.

It is a good time to start playing with Metalama. Because the team is no longer busy fixing severe bugs, once a new one appears, we can address it in hours or days.

PostSharp migration

Last month, we published the PostSharp API Annotated for Migration to Metalama. This month, we are announcing Metalama.Extensions.Multicast, an open-source emulation of PostSharp attribute multicasting for Metalama. Our design objective with Metalama is that you should not have to change your business code when migrating from PostSharp to Metalama, that it should be enough to migrate your aspect code.

We are still not completely done with the PostSharp-to-Metalama migration story: there is no documentation, and we want to release a package to report warnings and errors for the PostSharp API.

Support for Roslyn 4.4, C# 11 and .NET 7.0

We have merged Roslyn 4.4 into Metalama Compiler and fixed the issues with .NET 7.0. The new features of C# 11 are still not fully implemented in Metalama: you may still hit some bug if you use them.

We also published PostSharp 6.11 RC this week, with support for C# 11 and .NET 7.0.

Code Lens for Visual Studio

We added a new experimental feature to Metalama Tools for Visual Studio: integration with Code Lens. The feature shows you how many aspects are applied to any declaration. When you click on the summary, you will get a detailed list of all transformations applied to the declaration. The feature will be developed further after the RTM release according to users’ feedback.

CodeLens screenshot

LinqPad support

The Metalama driver for LinqPad has been fixed and greatly enhanced this month. The driver allows to query the code model of any .NET project, whether it uses Metalama or not. For Metalama-enabled projects, the driver lets you query the aspect model (aspects, advice, transformations, …).

LinqPad screenshot

What’s next

We are almost done for RC. There is still work with the documentation, the new C# 11 features, and with a few kinds of advice like overriding indexers or introducing generic interfaces.

We have also started the work to port the PostSharp ready-made aspects to Metalama. This is going to be a long-term project, but it’s good to see that it’s now in progress.

If you want to give Metalama a try, the best way to get quick feedback in real time is to join our Slack community. You can also submit bugs and feature requests from different channels. Your feedback is greatly appreciated as always.

Happy meta-programming with Metalama!

-gael

Announcing PostSharp 2023: Support for .NET 7.0 and C# 11

$
0
0

We are excited to announce the release of PostSharp 2023 today. PostSharp 2023 adds support for the latest version of the .NET stack and includes the ability to use both PostSharp and Metalama on the same machine. It is available for download on NuGet, Visual Studio Marketplace and our website.

Platform update

PostSharp 2023 adds support for .NET 7.0, C# 11 and Visual Studio 2022.4.

Note that PostSharp 6.10 remains our long-term supported (LTS) release, as .NET 7.0 is not an LTS version of .NET.

Metalama compatibility

As many of you may already know, we have been working hard on Metalama for the last two years. Metalama is our next-generation meta-programming platform, entirely based on Roslyn instead of MSIL rewriting. This new version of PostSharp is designed to be compatible with Metalama, allowing teams to use both technologies during a transition period. In concrete terms, PostSharp Tools for Visual Studio will no longer suggest the option to add an aspect to a project if the package that implements that aspect is not already added to the project. We have removed the ability to automatically add PostSharp packages to projects. This feature was built before NuGet existed; it was still marginally useful during NuGet’s infancy but is now considered redundant.

Please keep in mind that it is not recommended to use PostSharp and Metalama in the same project. By compatibility, we mean that the two can be used on the same machine, but in separate projects.

We’ve also switched to calendar versioning for all our products.

Summary

This release shows our commitment to keeping PostSharp up-to-date with the .NET platform and supporting the thousands of companies that rely on it. Even several years after Metalama becomes a complete replacement for PostSharp, we’ll continue to provide support and maintenance for our classic product line.

Happy PostSharping!

New Versioning Scheme

$
0
0

Starting from January 2023, releases of PostSharp and Metalama will be numbered 2023.0, 2023.1, 2024.0, 2024.1 … We will also be taking some liberties with the backward compatibility guarantees granted by the Semantic Versioning standard.

At PostSharp Technologies, we have been early adopters of semantic versioning since 2013. However, looking back at the last 10 years, we think it’s time for a change. The main problem we have with semantic versioning is with the rule that links the bumping of the major version component to the introduction of breaking changes. In retrospect, we have noticed that we have always tried to maintain backward compatibility regardless of the major version component. Like most software houses, we accelerated our pace of delivery and now deliver a continuous stream of value rather than a major release every couple of years. In this context, a versioning scheme that imposes a strong difference between a major and minor version no longer seems to make sense, and we feel it’s time to join the industry trend of year-based versioning (or CalVer ), e.g. 2023.0.10, 2023.1.11-preview, 2024.0.20-rc.

We will now follow the scheme YYYY.N.B[-preview|-rc], where:

  • YYYY is the current or next year,
  • N is the version number within this year,
  • B is the build number within the minor version,
  • -preview indicates that the product is of pre-release quality and may still be subject to significant changes,
  • -rc indicates that the product is of release candidate quality, which means that all quality gates for this version have passed and that we are waiting for more confirmation from users.

We will no longer make a difference between a major and a minor version, there will be just versions and builds.

Contrary to the SemVer specification, we will allow for breaking changes even when we will not change the YYYY component of the version number and will change the YYYY component even if we don’t have any breaking changes.

So, when do we do breaking changes? We don’t want to give hard rules, but we will apply practical judgment based on the following principles:

  • We will never do a breaking change within a stable YYYY.N version unless it is absolutely necessary to fix a bug.
  • Before removing an API, we will mark it as [Obsolete] and keep backward compatibility for some time.
  • We will treat old APIs with more respect than new ones. We will not feel obliged to maintain a deprecated API longer than its non-deprecated lifetime, unless the API was included in a long-term-support (LTS) release.

We will apply this new versioning change in our next releases of PostSharp and Metalama.

Happy meta-programming with PostSharp and Metalama!

Metalama Pricing Model: Affordable, Flexible, and Open-Source Friendly

$
0
0

With the release of the first Release Candidate of Metalama, we are thrilled to unveil a new pricing model that offers both flexibility and affordability. As a result of this new model, we are excited to progressively release all of our ready-made aspect libraries as open-source projects.

Our new product will be available in four different editions, including a completely free version. Our commercial editions, Metalama Starter, Metalama Professional, and Metalama Ultimate will range in price from $60 to $160 for individuals. Prices for businesses range from $40 to $400 per developer depending on the edition and the number of concurrent users. See our price calculator for details.

The main distinction between the various editions of Metalama is the number of aspect classes or libraries that can be used in each C# project. Each edition grants a certain number of credits, which can be used to access any aspect. As we move forward with porting the PostSharp.Patterns ready-made aspect libraries from PostSharp to Metalama, we are excited to announce that these new libraries will be available as open-source projects. This means that you will be able to inspect the source code and modify it to suit your needs, all within the framework of the credit-based pricing system.

Aspect Credits

The Metalama Free edition includes 3 aspect credits. Credits are consumed as follows:

  • Custom aspects, i.e. aspects written by your own team, consume 1 aspect credit per aspect class.
  • Third-party aspect libraries, i.e. aspects written by external contributors (whether open source or not), consume 1 aspect credit per aspect library, regardless of the number of aspect classes, assemblies, or packages that the library contains.
  • First-party aspects, i.e. aspects written by our team and released as open-source projects, generally consume 1 aspect credit per aspect class, however, certain aspects may consume fewer credits.

This means that Metalama Free allows you to use up to three third-party aspect libraries free of charge! All third-party aspect libraries will have access to all features of Metalama without any limitations. This includes advanced aspect-oriented programming, architecture validation, code refactorings & live templates, and transitive fabrics.

The commercial editions of Metalama add credits and features as follows:

  • Metalama Starter, priced from $60 per developer, allows for 5 credits in total and adds:
    • fabrics, which allow you to use a simple and extensible fluent API to validate your code against architecture and add aspects in bulk,
    • inheritance of custom aspects,
    • ability to debug the transformed code, instead of just the source code.
  • Metalama Professional, priced from $100 per developer, allows for 10 credits in total and adds:
    • code refactorings & live templates for custom aspects,
    • aspect testing framework (i.e. Metalama.Testing.AspectTesting),
    • extensibility using Roslyn (i.e. Metalama.Framework.Sdk).
  • Metalama Ultimate, priced from $160 per developer, as the name suggests, does not have any limitations.

For a full feature matrix and price calculator, see our pricing page.

Open-Sourcing Metalama Extensions and Aspect Libraries

As we previously mentioned, we plan to open-source most of our codebases around our core technology. We have already open-sourced the following projects:

  • Metalama.Extensions - a set of extensions to Metalama.Framework, which includes code metrics, support for dependency injection in aspects, architecture validation, and PostSharp-compatible aspect multicasting.
  • Metalama.LinqPad - a LinqPad driver that allows you to inspect the code model of any C# project and, if it uses Metalama, the code model of compilation artifacts like aspect classes, aspect instances, advise, transformations, diagnostics…
  • Metalama.Community - implements ready-made aspects and other code transformations that do not stem from our own team, i.e. where our company is not the only contributor and copyright owner. It currently contains proof-of-concept implementations of a few Fody features: Costura (embeds dependencies as managed resources) and Virtuosity (makes all public methods virtual). It also implements an AutoCancellationToken aspect. The project mainly serves as an example to demonstrate low-level code transformation using Roslyn API.
  • PostSharp.Engineering - is our homegrown build front-end and SDK, which helps work with dependencies in a multi-repo product, consolidate code quality practices, generate TeamCity configurations…

As we will be making progress porting PostSharp.Patterns to Metalama, we will release these projects to GitHub as well, and everything will be available within the credit-based pricing framework.

Quasi-logarithmic Volume Pricing

One of the common criticisms of PostSharp’s pricing was that it was too costly for large teams. We have taken this feedback into consideration and are excited to introduce a new, quasi-logarithmic volume pricing model with Metalama. With business licenses, you will already receive a 5% discount for 2 concurrent seats, and that discount increases up to 75% for teams of 200 developers.

We believe that price should not be a barrier for anyone and with this pricing; teams who fully utilize Metalama’s potential can see a return on investment of 100x.

Early Bird Discount

We understand that Metalama is a new product and that it may take some time to resolve any issues that may arise. We greatly appreciate customers who choose to take a chance on our product and we are confident that it will be worth it.

To show our gratitude, we are pleased to offer a 50% discount to customers who purchase a Metalama license within the first three months after its GA release, and a 25% discount to customers who purchase within the following three months.

Open Source Projects

Supporting the open-source community is a top priority for us, that’s why we have decided to offer Metalama free of charge for open-source projects, to the benefit of both contributors and users.

Upon request, we will provide a redistribution license key, which will be linked to a specific code namespace. This key will allow any aspect within that namespace to utilize all features of Metalama, even if the users of your project are running the Metalama Free edition. All users will have access to up to 3 open-source aspect libraries at no cost.

As a token of appreciation for community contributions, we also offer a complimentary Metalama Ultimate license to core voluntary contributors. This license will allow them to use Metalama for all their personal and commercial projects.

Redistributing Commercial APIs

You can still supercharge your API with Metalama aspects, free of charge for your users, even if your product is commercial or closed-source.

Just as with open-source projects, upon request, we will provide you with a namespace-bound license key at no cost. This key will ensure that your customers have access to Metalama features without paying for a commercial version of Metalama. However, we do expect that you purchase a commercial license key for your team members. This ensures that both your team and customers have access to the full range of Metalama features, while also supporting our development efforts.

PostSharp Customers

As a PostSharp customer, your existing license key is already compatible with Metalama. Metalama Professional package is included in PostSharp Framework, and Metalama Ultimate package is included in the PostSharp Ultimate package.

Please be aware that while the features of Metalama Professional cover most of those of PostSharp Framework, they may not meet all of your requirements due to limitations on the number of aspect classes. Even if you currently hold a PostSharp Framework license, you may still need to purchase Metalama Ultimate or upgrade to PostSharp Ultimate, which includes Metalama Ultimate. Conversely, if you are currently using the PostSharp Ultimate package, the features of Metalama Professional may be sufficient for your needs, so may lower your license costs after migrating to Metalama.

Customers who have a substantial number of PostSharp Framework licenses can reach out to us to obtain a complimentary Metalama Ultimate license, provided that the cost of Metalama Ultimate licenses is not more than 80% of the cost of PostSharp Framework licenses for the same number of seats.

Summary

Metalama is our new meta-programming solution that is built on Roslyn technology. It provides a pricing model that is both flexible and affordable, making it accessible to teams of all sizes, including open-source projects. Its integration of AOP, architecture validation, and coding assistance makes it a powerful tool for improving the code quality and increasing the productivity of any C# development team. Metalama is currently in the Release Candidate stage, and we encourage you to try it in your projects. We have received feedback that it has already been deployed to several teams with success.

Announcing Metalama RC

$
0
0

Today, we’re thrilled to announce the first Release Candidate of Metalama, our new Roslyn-based meta-programming framework for aspect-oriented programming and architecture validation.

About Metalama

If you haven’t heard about it yet, Metalama is our new meta-programming framework for C# that focuses on improving developers’ productivity and code quality thanks to boilerplate code reduction through aspect-oriented programming, coded architecture validation and a custom refactoring toolkit. Metalama is based on Roslyn and integrates with most C# IDEs and editors. You can learn more about it on our website or your can try it online.

While Metalama is the successor of PostSharp, it is not yet a replacement. We do not recommend migrating your projects from PostSharp to Metalama at this time unless you’re certain that all the features you need are already available. We’re working on this, and for more details, please see our migration guide. Rest assured, we’re still committed to maintaining and supporting PostSharp, as evidenced by the recent release of PostSharp 2023.

About this RC

Our first version will be numbered 2023.0, since we’ve switched to year-based versioning.

The Release Candidate milestone signals that Metalama is code-complete, has no severe bugs, and has not required any destabilizing refactoring in the past weeks. Users of the preview version have given us positive feedback, and Metalama has already been deployed to some development teams for production work.

As an engineering company at heart, the Release Candidate milestone holds great importance to us. We began working on Metalama in August 2019 and have dedicated the majority of our efforts towards this project since January 2020. Metalama represents a major achievement for us, and we are incredibly proud of it.

We would like to express our sincerest gratitude to everyone who has tried Metalama, provided feedback, and reported bugs during the past few months. Our utmost appreciation goes to Marc Kruse, who created an outstanding suite of aspects for his ORM-based application and reported an impressive 80 tickets. We would also like to give special thanks to Vladut Alecsandru and his colleagues, Peter Hevesi, Goran Siska, and YBAZAN for their invaluable feedback. You can connect with these fine developers in our Slack community.

New Pricing Model

In addition to the release of Metalama, we’re also unveiling a new pricing model. A powerful and completely free edition is available, with commercial options ranging from $40 to $400 per developer, depending on the product edition and the number of concurrent developers. We’re also releasing several components and extensions of Metalama as open-source projects, and we plan to release the migrated PostSharp.Pattern aspect libraries as open-source projects as well. For details about the new pricing model, read our announcement.

What’s New Since the last update

If you have been following the monthly status updates, here is what’s new since our last report.

Since December 1st, we have addressed approximately 100 bug fixes or small enhancements. For details, see the change log of individual builds. We have also completed minor user stories like:

  • Handling of [CallerMemberName] custom attributes.
  • Moving Metalama.LinqPad to its own repository and made it open source.
  • Adding conditionally inheritable aspects (IConditionallyInheritableAspect).
  • Disabling obfuscation.
  • Renaming the metalama-config CLI tool to metalama and improving it.
  • Adding support for local functions in templates.
  • Adding limited support for introducing generic interfaces from aspects.
  • Allowing customization of the appearance of the aspect in the IDE code refactoring menu with the [EditorExperience] custom attribute.

The only big addition of the last 2 months is the long-awaited Architecture Validation component, released under an MIT license in the Metamama.Extensions repo. The documentation for this component is still being written. In summary, there are two ways to use this package:

  1. By adding to your code one of the following architecture custom attributes from the Metalama.Extensions.Architecture.Aspects namespace:
    • [CannotBeUsedFrom]
    • [CanOnlyBeUsedFrom]
    • [InternalsCannotBeUsedFrom]
    • [InternalsCanOnlyBeUsedFrom]
    • [Experimental]
    • [InternalImplementOnly]
    • [DerivedTypesMustRespectNamingConvention]
    • [DerivedTypesMustRespectRegexNamingConvention]
  2. By using fabrics, for instance:

    namespaceSomeNamespace;usingMetalama.Extensions.Architecture.Fabrics;usingMetalama.Framework.Fabrics;publicclassFabric:NamespaceFabric{publicoverridevoidAmendNamespace(INamespaceAmenderamender){amender.Verify().InternalsCanOnlyBeUsedFrom(UsageRule.OwnNamespace);}}

What’s Next

Before announcing General Availability, we will continue to fix bugs and complete the documentation and the product website, in preparation for the commercial launch of the product. We will continue to provide support in our Slack community or on GitHub and swiftly fix any reported bug. We will no longer accept enlarging the scope of this version.

Summary

We believe that Metalama will transform the way developers write code and, in particular, how senior developers and architects optimize their team’s workflow and improve quality and productivity.

Today marks a major achievement for our company as we reach a significant engineering milestone. As a company run by engineers for engineers, this is a particularly meaningful day for us. After extensive testing and feedback from internal and external sources, we are confident that Metalama is ready for use in real-world projects. We have received positive feedback from satisfied users, and any bugs encountered will be addressed promptly. If you’re starting a new project, now is the perfect time to integrate and learn Metalama.

Metalama Status Update (February 2023)

$
0
0

After two major announcements last month, February was a quieter month for us. In addition to improving our API and fixing bugs, we added a new CLI command to analyze the use of licensing credits. We also integrated customer code into our continuous integration pipeline for the first time.

API Improvements

We’ve made improvements to the Invoker API, which includes methods and properties of the compile-time code model that enable your templates to generate code that accesses these declarations at runtime.

Previously, you had to write code like this:

method.Invokers.Final.Invoke(meta.This,"Hello, world");varpropertyValue=property.Invokers.Final.GetValue(meta.This);

Now, you can simply write:

method.Invoke("Hello, world.");varpropertyValue=property.Value;

We’ve also simplified working with IExpression. You can now pass an IExpression as an argument to a dynamic parameter, and you can cast any dynamic expression to IExpression instead of using meta.Capture.

Although these API improvements were planned, we did not anticipate so many changes, nor such a big improvement in usability. We’re pleased to report that the result is better than expected. We regret not making these improvements before the RC but we’re pleased that we did so before GA. These were the last planned API improvements, so any future changes should be minor and should not break compatibility.

Bug Fixes

We’ve recently focused on addressing some low-priority bugs that were discovered during our internal testing but were not reported by external users. Although most of these issues were quickly resolved, one of the fixes proved to be more challenging and led to a few regressions, which negatively impacted the quality of builds 2023.0.102-rc to 2023.0.104-rc. However, we’ve since resolved those issues and are pleased to report that the quality of our builds is once again very high.

In total, we’ve addressed around 40 bugs, including half a dozen regressions, and have also fixed a few memory leaks at design time. Needless to say, we were concerned and disappointed by the regressions, so we took steps to address the issue and prevent similar problems from arising in the future.

Supply Chain Integration

For the first time, we’ve integrated customer source code into our continuous integration pipeline. A long-time customer shared their Metalama aspects and test suites with us, and we stored this code in an Azure DevOps repo that we both have access to. The customer’s test suite is now part of our own test suite and will be verified during every nightly build and before every release.

This collaboration brings great benefits to both parties. It provides a proactive approach to detect potential regressions that could affect the customer, significantly reducing the risk of productivity loss due to Metalama bugs. Furthermore, when API changes occur in the future, we will promptly update the customer’s code, enabling them to easily review the changes and ensure seamless integration with Metalama.

Note that we only have access to a copy of a subset of the customer’s codebase that includes aspects and their corresponding tests. We do not have access to the entirety of the customer codebase.

We’d love to extend this experiment to other customers. If you are interested, please contact me directly.

Analyzing Licensing Credits Usage

Last month, we introduced a new pricing model where the main differentiator between product editions was the number of credits that can be consumed by a project. In the latest build, we’ve included a new command, metalama license credits, that lets you analyze the number of credits that your projects are consuming and why. This tool is especially useful when your trial period is ending and you need to determine which Metalama edition is right for you.

Documentation

We’ve focused more on improving our documentation this month. We’ve added a new chapter, Using Metalama, which is dedicated to people who will use Metalama but won’t create their own aspects (this group accounts for 90% of users in a typical medium-to-large company). We’re currently working on other chapters and the technical infrastructure of our documentation.

Summary

In February, we made significant improvements to our API, fixed bugs, integrated a customer’s code into our continuous integration pipeline, added a new CLI command to analyze the use of licensing credits, and worked on improving our documentation. We’re pleased with the progress we’ve made, and we’re happy to announce that Metalama is now technically ready for GA. However, before we release the product, we’d like to see a couple of weeks without regressions. Our next milestone is to complete the documentation and product website, after which we’ll be fully prepared for the launch!

As always, we’re committed to providing the best possible experience for developers, and we encourage you to reach out to us on GitHub forum or our Slack community with any questions or feedback you may have. Thank you for your support, and happy meta-programming with Metalama!

-gael


Metalama Status Update (March 2023)

$
0
0

We have been working hard this month to improve the documentation and fix bugs in preparation for a release around May 1st, 2023. We have also added a very last feature that would ease divorcing from Metalama, should the need arise.

Documentation is a feature

Clear and comprehensive documentation is crucial for a tool as broad and complex as Metalama. That’s why we’ve been working hard to improve our documentation in several ways:

  • We added a new chapter on verifying architecture, which explains how to use the Metalama.Extensions.Architecture namespace to validate source code against your architecture. You’ll learn to define architectural rules, such as dependencies or naming conventions, and how to enforce these rules using custom attributes and fabrics.
  • We added another new chapter on using Metalama, aimed at developers who participate in projects using Metalama but don’t write aspects themselves. You’ll learn to install Metalama in your development environment, apply aspects to your code, see which aspects have been applied, and understand and debug your aspect-oriented code.
  • We revamped the documentation website, integrating the examples and the online sandbox with the documentation, and improving the representation of errors and warnings in source code.

We hope these improvements will make it easier for you to learn and use Metalama. We welcome your feedback and suggestions on how to make our documentation even better.

Divorce… also

We have introduced a divorce feature to Metalama, and it’s not what you think. It’s not a feature that will send you into a spiraling emotional meltdown, like a real-life divorce. Instead, it’s a feature that allows you to part ways with the framework gracefully and efficiently, like a break-up between two adults who have had enough of each other.

With the metalama divorce command, the code usually generated in the background during compilation is injected into your source code, leaving you free to exit the framework without experiencing daunting code separation challenges. It’s like a considerate ex-partner who helps you pack your bags and move out of the apartment.

Other fixes and improvements

We fixed around 30 bugs in March 2023, with lower and lower severity. It seems that there is no longer any release blocker. You can see the complete list of bug fixes in the release announcements on our GitHub discussion board.

We also added support for Roslyn 4.5, the latest version of the .NET compiler platform. It seems that it only contained bug fixes.

What’s next

We think that Metalama is now mature and we are planning for a release around May 1st, 2023. We will continue focusing on bug fixes, documentation, and the promotional website. We’re excited about this release and hope you are too. We want to thank you for your support and feedback throughout this journey. Remember that you can join our Slack community and chat directly with our team. We believe that Metalama will change the way you write C# code for the better. Stay tuned for more updates, and happy coding!

Metalama is Available Today

$
0
0

Metalama, the new meta-programming framework aimed at helping developers deliver clean and concise code, is now available for production use. We are giving a 50% discount on all Metalama licenses until the end of July to celebrate this release.

What is Metalama?

Metalama helps C# developers improve their productivity and code quality. It offers the following benefits:

  • Reduce boilerplate by generating it dynamically during compilation thanks to aspect-oriented programming. Your source code remains crystal-clear.
  • Verify code in real time against architecture, patterns, and conventions. No need to wait for code reviews.
  • Provide coding assistance to your team with customized feedback and suggestions.
  • Do it by your rules. Automate your own implementation patterns and architecture guidelines.

Based on Roslyn, Metalama integrates with most C# IDEs and editors including Visual Studio, Rider, and Visual Studio Code.

Developed since August 2020, it has been serving real users since July 2022. We have integrated their feedback and fixed countless bugs to reach this point where we can now say that Metalama is ready for production

You can learn more about Metalama and its features on this website.

Top Features

T# Templates

Leverage the power of T#, a markup-free, C# syntax-compatible template language with Visual Studio syntax highlighting.

T# Templates

Override Anything

Unlike proxy-based AOP frameworks, Metalama is not limited to interfaces and virtual methods.

Override Anything

Aspect Inheritance

Automatically apply aspects to child classes by marking parent classes — even across projects.

Aspect Inheritance

Fabrics

Implement compile-time project entry points for aspect addition or code validation.

Fabrics

Intellisense

Access aspect-introduced code in real-time, without recompiling.

Intellisense

Instant Diagnostics

Receive real-time error and warning notifications from aspects in the editor.

Instant Diagnostics

Diff Preview

Seamlessly compare source and transformed code within Visual Studio.

Diff Preview

CodeLens

Quickly identify applied aspects in the editor even when it is not obvious from source code.

CodeLens

Custom Fixes & Suggestions

Develop team-specific code fixes linked to diagnostics.

CodeLens

Syntax Highlighting

Easily distinguish meta code with T# color-coding.

T# Templates

Debugging Flexibility

Select between stepping into the transformed code or staying within the source code.

Debugging

Testing Framework

Efficiently test aspects on various target declarations with the integrated Visual Studio or Rider test runner.

Testing Framework

Querying Interactively

Use the Linqpad driver to query your codebase interactively like a database and analyze the behavior of your aspects and fabrics.

LinqPad

No Vendor Lock-In

Export transformed code and revert to vanilla C# anytime.

Divorce

Extensible with Roslyn

Overcome the limitations of Metalama and write transformations directly with Roslyn.

Extensibility

Open-Source Extensions

Access a range of published extensions and samples under open-source licenses.

Extensions

Metalama vs PostSharp

While Metalama is the successor to PostSharp, it is not yet a replacement, and migration from PostSharp is not recommended at this time unless all features required by your projects are available in Metalama. For more details, please see our migration guide.

PostSharp is still being maintained and supported, as demonstrated by the recent release of PostSharp 2023. If you are a PostSharp user, we suggest you consider Metalama for new projects. Your PostSharp license already includes Metalama.

Try Metalama today

If you’re ready to transform the way you write code, get started in these three steps:

  1. Explore the examples and try them in the online sandbox.

  2. Install the Metalama Tools for Visual Studio. It’s optional, but we recommend it, especially if you’re just starting.

  3. Clone the Metalama.Samples repo, and start exploring!

Special Promotion

To celebrate the release of Metalama, we are offering a 50% discount on all Metalama licenses until the end of July. Don’t miss this limited-time opportunity to start using Metalama at a discounted price.

Summary

Today we released Metalama, an innovative meta-programming framework aimed at elevating C# developers’ productivity and refining code quality. Now production-ready, Metalama provides a wealth of features such as T# templates, aspect inheritance, fabrics, instant diagnostics and code fixes, and broad compatibility with multiple C# IDEs. While not an outright replacement for PostSharp, it is the ideal choice for new projects. Don’t miss the limited-time 50% discount on all Metalama licenses, available until the end of July, and embark on a transformative coding journey with Metalama today!

Metalama Status Update, May 2023

$
0
0

May bloomed with beauty and excitement, setting the stage for a long-awaited event — the release of Metalama, our new Roslyn-based meta-programming framework, on May the 4th! With 2.5 years of dedicated effort poured into this product, its launch marked a significant milestone for our team. Fortunately, the release went smoothly, with only minor bugs reported, aside from a slightly embarrassing but now fixed glitch following the release of Visual Studio 17.6.

Metalama 2023.1 Previews

In the wake of the general availability of Metalama 2023.0, we wasted no time introducing the initial previews of Metalama 2023.1, a bug-fixing release. Our development timeline for the summer includes two to three bug-fixing releases, consisting of six weeks of development followed by three weeks of RC (Release Candidate) testing, amounting to a total of nine weeks. Consequently, the RC for Metalama 2023.1 is scheduled for June 5th!

Roadmap

Looking forward, Metalama 2023.2 will focus primarily on bug fixing. Like Metalama 2023.1, this version will follow a nine-week development cycle with a flexible scope. Our main objective remains the resolution of bugs, ensuring we tackle the extensive backlog of minor issues before advancing with new feature implementations.

In 2023.2, we also want to incorporate a few new minor features based on user feedback. For instance, we want to improve the experience with weaver-based aspects, which allow you to perform arbitrary code transformations thanks to the Roslyn API. Caution: It voids the warranty!

Once we have completed the bug-fixing phase and beyond the horizon of the 2023.2 release, we will focus on the following priorities:

  1. Merging the PostSharp and Metalama Visual Studio extensions to create a unified experience and enhance Metalama’s IDE features to match those of PostSharp.
  2. Porting pattern libraries for which Metalama is already equipped, such as Contracts, NotifyPropertyChanged, XAML, and Caching. We intend to release these ported pattern libraries under the open-source MIT license.

The threading pattern libraries’ complexity warrants a longer wait, primarily because it requires the aspect framework to be able to advise the await keyword. As for logging, Metalama currently boasts excellent logging capabilities without the need for the port of PostSharp.Patterns.Diagnostics. Hence, we consider it a lower priority. Nevertheless, we are open to hearing your thoughts on this matter, so please don’t hesitate to share your opinion.

Support policies updated

Kindly be aware that we have revised our support policies due to the rapid release cycle of Metalama. Moving forward, we will only provide maintenance and support for three product versions simultaneously, generally including a stable version, a release candidate (RC), and a preview version. Our previous policy ensured maintenance for two months after the subsequent version’s general availability (GA). However, this policy is incompatible with our current 9-week release cycle.

Website

Together with the Metalama release, we have made updates to our website. The blog and documentation sections are now integrated into the main navigation and provide a smoother user experience. Additionally, we have made some improvements to the community portal to emphasize the contributions of everybody.

PostSharp bugfixes

Besides the work on Metalama, we have released a patch of PostSharp 2023.0, fixing a rare condition when referencing managed C++ assemblies.

Community

I want to express my gratitude to all the community members who have provided valuable feedback and contributions. Whether it’s bug reports, articles, examples, or even just a heads-up on obscure documentation, every bit of input has been beneficial and encouraging.

I highly recommend checking out Dom Sinclair’s delightful article, The Art of Logging. And if that was not enough, Dom is currently working on a semantic logging aspect for Serilog that utilizes the new interpolated string handler feature of C# 10.

To support the growth of our community, we have created a server on Discord, the most popular community platform among developers. However, since some people prefer using Slack, we will run two separate communities for now - one on Slack and the other on Discord. GitHub remains the preferred place to file bugs and feature requests after a good discussion on Slack or Discord. The other social platforms, Twitter and LinkedIn, will be used for announcements, and we expect little interaction to happen there.

We plan to conduct regular office hours featuring Q&A, status updates, and occasional demos by the Metalama team and the community. The specifics are yet to be determined. We invite you to join us on either Discord or Slack to get informed.

Summary

May was an eventful month for us with the successful launch of Metalama and revamping our website and community platforms. Thankfully, the launch was smooth, with only minor bugs reported and quickly resolved. We have shifted our focus to fixing minor bugs with Metalama 2023.1 and 2023.2.

Metalama 2023.1 is Generally Available

$
0
0

I am pleased to inform you that Metalama 2023.1 is now available to the public. This update focuses on bug fixes and platform support, adding compatibility with Visual Studio 17.6 and over 50 bug fixes and minor enhancements.

Metalama 2023.1 includes the following enhancements:

  • Added support for Visual Studio 17.6, Roslyn 4.6, and .NET SDK 7.0.300.
  • The IAdviceFactory.ImplementInterface now exposes the created members in IImplementInterfaceAdviceResult.
  • Introducing the new extension method IType.ToTypeOfExpression(), which returns an IExpression.
  • Contracts now support IEnumerable.
  • Ability to make an introduced field readonly.
  • Improved error reporting for aspect members with more than one advice/template attribute.
  • Enhanced error message when referencing a non-existing type in compile-time code.
  • In templates, foreach loops are now allowed in run-time-conditional blocks.
  • Better error reporting when the [Template] attribute is used on accessors.

For a detailed list of bug fixes, please refer to the change log for individual builds.

Please note that 2023.1 addresses a severe memory leak in Visual Studio, so we highly recommend taking this update.

As previously announced, we only address severe bugs in versions that have reached the RC stage. This approach ensures that we maintain the stability of our releases and minimize the risk of introducing instability. Consequently, we are now delivering more frequent updates with fewer enhancements but a greater focus on bug fixes. Our next bug-fixing release, Metalama 2023.2, is now in public preview and is scheduled for RC on July 17th.

I would like to apologize for the difficulties that occurred with the Visual Studio 17.6 update. The impact of these difficulties was limited due to the relatively small user base of Metalama. Upon careful analysis, we have identified the root cause of this problem as a failure to restructure our engineering processes effectively when transitioning the Metalama project from R&D to production. Rest assured: we are currently reorganizing our operations to ensure that Metalama undergoes thorough testing before new versions of Visual Studio undergo are made generally available.

Happy meta-programming!

-gael

Metalama Status Update, June 2023

$
0
0

Greetings, fellow clean code enthusiasts! As we bid farewell to June and its barbecues, I am thrilled to serve up some fresh updates straight from the Metalama kitchen: a GA, a preview, a new project, and a community initiative!

Metalama 2023.1 GA: Now Available

Our first announcement this month is the general availability of Metalama 2023.1. This release includes support for Visual Studio 17.6. Additionally, we have implemented eight minor improvements and addressed 50 bugs, now mostly minor ones. For a detailed overview of what this release entails, check out our release announcement.

Metalama 2023.2 Preview

We have recently launched the first preview of Metalama 2023.2. Similar to 2023.1, 2023.2 will primarily focus on bug fixes, with six weeks of development and three weeks of RC stabilization. The first Release Candidate is expected to be available on July 17th.

Porting PostSharp.Patterns to Metalama

As part of our ongoing efforts to make Metalama a worthy replacement for PostSharp, we have initiated the process of porting PostSharp.Patterns, our well-established library of pre-built aspects, to Metalama. We are proud to announce that the entire Metalama.Patterns library will be available under the open-source MIT license. While we haven’t released a NuGet package just yet, you can track our progress on our GitHub repository. I am delighted to inform you that we have successfully completed the first version of Contracts, with all tests inherited from PostSharp displaying a promising green light. Currently, our focus is on Caching!

The initial components of Metalama.Patterns will be included in the 2023.2 release. However, please note that these packages will remain in the preview stage, even after the other 2023.2 packages become publicly available.

Introducing Office Hours

To strengthen our community and facilitate more direct interactions, we are excited to introduce office hours. Based on a community poll, these sessions have been scheduled for Thursdays at 5 PM, Central European Time. This time slot has been specifically reserved for you. Don’t hesitate to book your seat online.

Furthermore, we will be recording these sessions and uploading them to our YouTube channel for those who wish to catch up later.

Metalama: An Introduction Video

We have recently released an introductory video for Metalama. Would you like to hear me discuss code with my distinct Belgian-French accent? Watch the video on YouTube and feel free to share it with interested colleagues or friends.

We encourage you to join us on Slack or Discord to seek help or just stay up to date with all things Metalama.

Until next time, happy meta-programming!

-gael

Metalama 2023.2 is Generally Available

$
0
0

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!

Metalama Status Update, July-August 2023

$
0
0

Though July and August are usually slower months for us, this year we’re excited to bring you some major updates. We’ve open-sourced two key libraries for Metalama—Code Contracts and Caching—which together comprise 47,000 lines of code. Our template language, T#, has also been enhanced, allowing templates to call other templates. We’ve simplified the use of Roslyn from your aspects and have launched nine video tutorials to help you get started.

Metalama 2023.2 General Availability

On August 7th, Metalama 2023.2 was officially released, featuring 32 bug fixes and 5 minor improvements, but no new features. For more details, check the official announcement.

Metalama 2023.3 Code-Complete Preview

We’re thrilled to announce that Metalama 2023.3 is now code-complete, bringing significant new features along with 18 minor improvements and 44 bug fixes.

All packages have been uploaded to nuget.org and we recommend you also download and install the new Visual Studio extension

Code Contracts

Our Code Contracts library is an open-source, aspect-oriented implementation of System.ComponentModel.DataAnnotations. Unlike Microsoft’s annotations, Metalama’s Code Contracts works with any C# code, not just ASP.NET MVC or Entity Framework, as it utilizes aspects to inject validation logic during compilation.

You can use a range of contracts like Required, EmailAddress, StrictlyLessThan, and many more.

If you’re already using PostSharp code contracts, migration is straightforward with minimal code alterations, as we only changed the way exception messages and types are customized.

In Metalama, customizing the type and text of exceptions thrown is as simple as overriding the ContractTemplates class and setting your implementation to LoggingOptions.Templates.

For those who often have to verify public APIs for non-null arguments, we’ve simplified the process to one line of code per project:

amender.Outbound.VerifyNotNullableDeclarations();

This is a feature we’re particularly proud of!

Caching

We’ve also ported our PostSharp-based caching framework to Metalama and completely open-sourced it. We updated the codebase to take full advantage of modern .NET and C#, including the use of IReadOnlySpan<char> to further reduce garbage collection load.

If you’re unfamiliar with PostSharp Caching, it offers a robust set of features:

  • Method results caching based on parameters with the [Cache] attribute.

    partialclassCustomerService{[Cache]CustomerGetCustomer(stringcustomerId){// Database logic.}}
  • Direct cache invalidation using the [InvalidateCache] attribute.

    partialclassCustomerService{[InvalidateCache(nameof(GetCustomer))]CustomerUpdateCustomer(stringcustomerId,stringname){// Database logic.}}
  • Programmatic direct cache invalidation:

    partialclassCustomerService{CustomerUpdateCustomer(Customercustomer){_cachingService.Invalidate(GetCustomer,customer.Id);// Database logic.}}
  • Indirect cache invalidation through dependencies:

    partialclassCustomerService{[Cache]CustomerGetCustomer(stringcustomerId){CachingServices.CurrentContext.AddDependency(newMyDependency(nameof(Customer),customerId));// Database logic.}CustomerUpdateCustomer(Customercustomer){_cachingService.Invalidate(newMyDependency(nameof(Customer),customerId));// Database logic.}}
  • Full customization of the cache key generation mechanism.

  • Support for various caching topologies, including local in-memory, Redis-based network caching, two-layer caches, and distributed caching via Azure Service Bus.

Transitioning from PostSharp to Metalama should be relatively smooth; most of the unit tests, honed over a decade, have been retained. However, you may first need to disable the dependency injection feature:

[assembly:CachingConfiguration(UseDependencyInjection=false)]

T# Templates Now Support Nested Calls

We’ve lifted a notable constraint from earlier versions of T#: templates now have the capability to invoke other template methods.

A “template method” is defined as any method adorned with the [Template] custom attribute. Although these methods can be static, the enclosing class must implement the empty interface, ITemplateProvider.

There are two approaches to invoking one template from another:

  • Statically: Simply call the template method in the usual C# manner. Note that these methods can also be virtual.

    publicoverridedynamic?OverrideMethod(){LogStart();// Additional logic.}publicoverrideasyncTask<dynamic?>OverrideAsyncMethod(){LogStart();// Additional logic.}[Template]protectedvirtualvoidLogStart(){this._logger.Log($"Method {meta.Target.Method.Name} is starting.");}
  • Dynamically: Utilize meta.InvokeTemplate, supplying both the parameters and type parameters. This method is particularly useful when working with strongly-typed templates that use generic method parameters, and you wish to bind the generic parameter to an IType.

The current limitation is that templates can only be invoked as a statement, not as an expression. In other words, you can’t capture a return value from the invoked template.

We’re working on expanding our documentation to cover this new feature, which is extensively utilized in our code contracts library. For a hands-on example, you can start by examining RegularExpressionBaseAttribute.cs.

Enhanced Capabilities with Metalama.Framework.Sdk

You can now seamlessly use the Roslyn API for low-level code model analysis using the Metalama.Framework.Sdk package. Although this package was available before, it wasn’t directly accessible from an aspect project. That limitation has been removed.

When adding this package to your project, it’s important to set all assets to private. This ensures that neither the package nor its dependencies, including Roslyn, get propagated to the consumers of your project or packages.

<ItemGroup><PackageReferenceInclude="Metalama.Framework.Sdk"PrivateAssets="all"/></ItemGroup>

For those interested in leveraging this feature, consult the conceptual documentation. You may also find the following examples illuminating:

  • INotifyPropertyChanged Dependency Graph: These examples demonstrate how to analyze the dependency graph of properties. For instance, they show how to detect when a change in the FirstName property necessitates updating the FullName property.

  • Metalama.Extensions.Metrics: This example reveals how to define metrics, a powerful but currently underutilized feature, aimed at tasks like measuring lines of code (LOCs) or gauging complexity. However, it’s worth noting that this is not yet usable from LinqPad.

  • Metalama.Community: This repository showcases how to craft aspects that perform arbitrary code transformations using the Roslyn API. Examples include making all methods virtual, automating the flow of CancellationToken, or embedding referenced assemblies as managed resources. Many of the aspects presented here are adaptations from Fody.

Debugging and troubleshooting

  • In the error list, with most errors and warnings reported by aspects, you can now see which aspect class and target declaration reported the diagnostic.
  • It is now possible to enable performance profiling of Metalama processes. See this documentation page for details.
  • Metalama Tools for Visual Studio has improved reporting of errors in compile-time code.
  • The debugging experience of templates and compile-time code has been dramatically improved. However, it is still required to use Debugger.Break() or meta.DebugBreak() to add an initial breakpoint.

Object model

  • A new property, IDeclaration.Sources, exposes references to the source code. You can now get any declaration’s file path, line, and column.
  • New overload IMethod.Invoke( IEnumerable<IExpression> ) to generate dynamic method calls.
  • Invoking a method from the target type with InvokerOptions.Base and an instance (other than base) is now possible if the base layer is in the current type.
  • Any aspect can now reflect on any other aspect instance (IAspectInstance) added before the current aspect thanks to the new API declaration.Enhancements().GetAspectInstances() returning an IEnumerable<IAspectInstance>. The previous method, GetAspect<T>, did not return the IAspectInstance and gave no access to the IAspectState.
  • Metalama.Extensions.DependencyInjection: You can now introduce a dependency programmatically.
  • RunTimeAspectHelpers has been improved.
  • New [RunTime] attribute that restricts to run-time the scope of a type that derives from a [RunTimeOrCompileTime] base class or interface.
  • IAdviceFactory: introduction methods now return the existing member for OverrideStrategy.Ignore.
  • AsyncEnumerableList<T>.Enumerator now has a Parent property which gets the AsyncEmumerableList<T> over which the enumerator enumerates. This allows methods such as BufferToListAsync<T> (see below) to avoid creating a new AsyncEmumerableList<T> when an enumerator is already based on an AsyncEmumerableList<T>.
  • RunTimeAspectHelper has new members new method BufferToListAsync<T>( this IAsyncEnumerator<T> ...) which buffers an async enumerator into an AsyncEmumerableList<T>, and returns the list. This supports scenarios such as caching.

Performance

  • The design-time performance of reference validators has been improved.
  • Performance improvement of Metalama.Framework.Workspaces, especially useful while using the Metalama driver for LinqPad.

Other

  • We merged Roslyn 4.7.
  • Overriding asynchronous methods with a template has been improved.

Video Tutorials

This summer, I’ve had the pleasure of creating 9 video tutorials to walk you through Metalama’s most crucial features.

What’s On the Horizon

Autumn typically marks the period when Microsoft completes its new version of .NET. As is our annual practice, we will wait for Microsoft to release the first Release Candidate and will ensure that both PostSharp and Metalama are fully compatible with the updated stack. Our aim is to release a PostSharp and Metalama Release Candidate one to two weeks after Microsoft announces the General Availability (GA) of .NET and Visual Studio.

Concurrently, we’re working on a fresh Metalama-based implementation of INotifyPropertyChanged. Unlike our previous efforts with caching and code contracts, we will not start from the PostSharp-based implementation. We plan to port only the unit tests from PostSharp, without striving to mirror its behavior exactly. Following this, our next goal will be to introduce dependency properties and integrate them with both code contracts and INotifyPropertyChanged. All of these developments will be released as open source.

If time permits, we’ll also aim to address some of the easier-to-implement features requested by the community.

In Conclusion

To sum up, it’s been an action-packed few months for us. We’ve rolled out a bug-fix update in Metalama 2023.2 and are on the cusp of launching Metalama 2023.3, which will introduce robust new features such as Code Contracts and Caching — both of which are now open-source — as well as noteworthy enhancements to T#. Stay tuned for forthcoming documentation, and do check out the new video tutorials to get up to speed efficiently.

Wishing you productive meta-programming adventures with Metalama!

-gael


Metalama Licensing Changes

$
0
0

In the upcoming Metalama 2023.3 release, we are implementing several changes to our licensing model. These adjustments aim to simplify the system while encouraging broader adoption of the Metalama platform.

Simplification of the License Credit Concept

In prior versions, our license credit system was somewhat complex. A single credit would be consumed for any aspect class, unless that class originated from a community-driven open-source aspect library. In such cases, the entire library consumed just one credit. The number of permitted aspect credits was determined by the Metalama product edition you had acquired.

Starting with Metalama 2023.3, we are eliminating the concept of license credits altogether. All aspect classes will now be counted equally, irrespective of their origin. This means there will no longer be a distinction between custom, community open-source, and first-party open-source aspects as was previously the case. We anticipate this modification will make our licensing model more transparent and easier to understand.

Namespace-Bound License Keys for Open-Source Projects

Open-source projects are welcome to utilize Metalama. Special license keys will be provided that can be checked into the Directory.Build.props file in your git repository. These keys will be bound to the root namespace of your project, allowing anyone building your project to use them.

However, it’s important to note that these license keys will no longer exempt aspects from your open-source library from the maximum aspect count determined by the product edition. While Metalama Free still includes three aspect classes at no cost, users may need to upgrade their edition to use more aspects.

Free Contract Aspects and Debugging Capabilities

To offset these changes, we are introducing two new features that will be available free of charge across all Metalama editions:

  1. Free Contract Aspects: Any aspect derived from ContractAspect, such as [Required], [EmailAddress], or any custom precondition checking aspect, will be completely free and won’t count against your aspect class limit.

  2. Free Debugging of Transformed Code: All editions will now be able to utilize the LamaDebug mode, allowing you to step into the transformed code.

Summary

The Metalama 2023.3 release aims to simplify our licensing model while providing additional functionality. We extend our gratitude to Onur for initiating this pivotal discussion and to all community members who contributed their insights on our #vip Slack channel. For any questions or clarifications, please feel free to reach out to us.

Thank you for your continued support and use of Metalama.

Metalama Status Update, September 2023

$
0
0

Ah, September — the season of fresh starts and nostalgic reflections. For those familiar with my journey, you may recall that PostSharp was my “creative outlet,” conceived in 2004 when my first daughter was born. It provided an intellectual diversion during periods when, like many new dads, I found myself navigating unexpected pockets of solitude. Fast forward to this September, and I’ve just assisted that same daughter in moving into her university dorm. Time certainly does fly!

But let’s pivot to software years — they’re akin to dog years, accelerating while we humans age more gracefully (or so we like to think). PostSharp, once my pet project, has matured into a seasoned veteran. While we’re not introducing many new features, we are updating it for compatibility with the forthcoming .NET 8 platform. Concurrently, Metalama is growing and finding its footing, similar to a young adult carving out their own path. We’ve refreshed its logo and are incorporating some of PostSharp’s best features. Trust me, progress is being made.

As Metalama continues its evolution, we decided it was time for a brand makeover. To bring this vision to life, we collaborated with the renowned graphic designer James Barnard.

New Metalama Logo The new logo has only been active for two weeks, but it already feels as if it has represented us for years.

Streamlining Open-Source Project Licensing

After rigorous debate within our Slack community, we’ve simplified the licensing options for open-source projects. Metalama Free will now allow up to three aspect classes per project, regardless of aspect origin — a significant simplification over our prior, more complex system. Additionally, Metalama Free will now offer two new complimentary features: unlimited contract aspects and the ability to debug transformed code.

We are also extending a free namespace-bound license key to open-source projects, granting full access to Metalama’s feature set within the scope of those projects. This change will be effective as of Metalama version 2023.3. For additional details, please refer to our article on the licensing changes.

Metalama 2023.3 Reaches RC Quality Standard

We’re excited to announce that Metalama 2023.3 has attained Release Candidate (RC) quality. This version marks the first major feature update since 2023.0, which mainly focused on bug fixes.

Key features include:

  • The introduction of two robust, professionally developed open-source aspects: code contracts and caching.
  • The ability to call T# templates, known as auxiliary templates, from other templates.
  • A comprehensive overhaul of Metalama.Framework.Sdk.
  • Numerous other enhancements and bug fixes.

For a thorough review of this release, you can consult our July-August 2023 status update. Since then, we’ve published several builds: 2023.3.7-rc, 2023.3.6-rc, and 2023.3.5-rc.

We anticipate Metalama 2023.3 will reach General Availability by mid-October.

Previewing Metalama 2023.4

Our development efforts are chiefly aimed at the upcoming Metalama 2023.4 release.

Key features to anticipate include:

  • A versatile options framework for configuring aspects through custom attributes or specific fabric-based APIs. This framework is in its final stages of stabilization.
  • A new, professionally crafted open-source aspect: INotifyPropertyChanged.
  • The transition of Metalama.Framework to a proprietary source-available license.
  • The open-sourcing of Metalama.Compiler, our customized fork of Roslyn.

We’ve released two preview builds: 2023.4.2-preview and 2023.4.1-preview.

Future Roadmap: PostSharp 2024 and Metalama 2024

Aligning with annual traditions, Microsoft unveiled candidates for .NET and C# this past mid-September. We’re actively exploring these new technologies with plans to update both PostSharp and Metalama. ARM support is a particular focus for us, considering Microsoft’s advancements in this area.

We also aim to merge the Visual Studio extensions for PostSharp and Metalama into a singular, cohesive development experience.

Our goal is to release our own RC shortly after Microsoft announces .NET 8’s general availability. We then plan to launch our General Availability (GA) release immediately after the holiday season.

Summary

In closing, as we shift more aspects from PostSharp to Metalama, we’re noticing Metalama’s increasing maturity. Most of the bugs we’re addressing originate from our own internal tests and development, rather than community reports. This bodes well for the platform’s stability.

In the weeks ahead, we’ll be updating both PostSharp and Metalama for compatibility with .NET 8 and C# 12. We’re also streamlining the Visual Studio extensions for both platforms.

Happy meta-programming!

-gael

Metalama 2023.3 is Generally Available

$
0
0

We are excited to introduce Metalama 2023.3, the most significant feature leap since our inaugural 2023.0 release. This update includes auxiliary templates, which make it possible for T# templates to call upon other T# templates and seamless integration with the Roslyn object model. Users will also benefit from a marked performance enhancement and a refined development experience. We’ve added support for the Visual Studio Code C# Dev Kit and simplified our licensing structure. We highly recommend you to update both the NuGet packages and Metalama Tools for Visual Studio.

Enhanced Nested Calls in T# Templates

We’ve addressed a prior constraint in T# templates by enabling them to invoke auxiliary template methods.

The advantages of utilizing auxiliary templates include:

  • Code reuse across templates.
  • The opportunity for abstraction and specialization through virtual and override templates.

For an in-depth understanding, our documentation offers a comprehensive guide.

Roslyn Access Through Metalama.Framework.Sdk

You can now tap into the Roslyn API for granular code model analysis via the Metalama.Framework.Sdk package. Previously, this package was available but not directly accessible from an aspect project — a limitation we’ve successfully eliminated.

Roslyn proves invaluable for:

  1. Analyzing method bodies within your aspect, for example, to examine the dependency graph of INotifyPropertyChanged.
  2. Executing arbitrary code transformations using low-level aspect weavers.
  3. Crafting metrics suitable for use in fabrics.

Streamlined Licensing

With Metalama 2023.3, we’ve simplified our licensing model, replacing the cumbersome concept license credits with simply counting the number of distinct aspect classes utilized per project.

We’ve also enhanced Metalama Free with unlimited contract aspects and the capability to debug transformed code over source code.

We now provide a complimentary namespace-specific license key for open-source projects, granting full access to Metalama’s entire feature set within the project.

For a detailed exploration, our blog post delves deeper.

Preview of Caching and Contracts

We’ve been diligently developing Metalama.Patterns.Contracts and Metalama.Patterns.Caching, two aspect libraries derived from PostSharp.

Currently, in v2023.3, their status remains in preview.

For those intrigued by these libraries, we recommend version 2023.4, set to reach RC shortly, in which both Metalama.Patterns.Contracts and Metalama.Patterns.Caching are set to become generally available.

Further Enhancements

Metalama 2023.3 includes a further dozen improvements in the following areas:

  • Developer experience: debugging, error reporting.
  • Performance: design-time code validation, LINQPad driver.
  • Supportability: ability to profile Metalama processes.
  • Object model: several new APIs.
  • 62 bug fixes

For details, see the release notes.

In Conclusion

Metalama 2023.3 marks significant progress in the framework’s development. The enhanced T# templates can now call other templates, enabling code reuse and abstraction in T#. Integration with the Roslyn object model has been streamlined, allowing aspect authors easier access to detailed code model analysis. Licensing has been simplified and clarified. Additionally, this release comes packed with numerous other refinements and bug fixes, optimizing the development experience and platform stability.

Open-Sourcing Metalama Compiler, a Roslyn Branch with Source Transformers

$
0
0

We are excited to announce the open-sourcing of Metalama.Compiler, the Roslyn fork used by Metalama to modify code dynamically during compilation. Metalama.Compiler enables anyone to build arbitrary source transformers.

The Metalama Compiler forms the foundation of Metalama, our high-level meta-programming framework that assists C# developers in reducing boilerplate using aspect-oriented programming and combating architecture erosion with architecture-as-code. The Metalama Compiler, representing several months of work, is a mature project that has seen no significant changes in the last 12 months, except minor bug fixes. By open-sourcing Metalama.Compiler, we aim to make it the preferred platform for Roslyn enthusiasts and SyntaxNode aficionados who want genuine source code generation capabilities. For application developers, building aspects based on Metalama.Framework is significantly simpler – not to mention that they can rely on a library of ready-made aspects on the Metalama Marketplace.

Why Did We Fork Roslyn?

Essentially, we forked Roslyn because we needed the ability to alter the code during compilation for our Metalama product.

When Microsoft introduced Roslyn in 2014, it was a game-changer for C# developers as it turned the traditionally opaque compilation process into a transparent and extendable API. Thanks to Roslyn, developers could see and use the rich information the compiler has about code. The initial extension points of Roslyn allowed any package to report custom warnings and errors using analyzers, suppress redundant warnings, and provide code fixes and refactorings. However, developers could not modify the code model.

In 2020, Microsoft took another step to open the compiler and introduced source generators, an extensibility point that allows any package to generate new source code – typically partial classes – and add them on-the-fly to the current project. The compilation process became open by addition. However, it was still closed to modifications, as there was still no way to modify an existing syntax tree.

At this point, I wrote a long and fruitful technico-philosophical essay on the cognitive nature of programming and how framework and language designers should avoid promoting hacks. As it turned out, my brain continued to think about this topic, and we soon started considering how to take advantage of these new Roslyn features to advance our ultimate mission – to improve the productivity of C# application development teams. We began to consider rewriting PostSharp, based on MSIL rewriting, to Roslyn. The first prototypes were completed between August 2020 and February 2021. This project became known as Metalama.

The first step was to fork Roslyn and open it for code modifications, not just additions. We added a concept of source transformer, just as there already were analyzers and source generators. This fork is Metalama.Compiler. It was maintained in a private repository from August 2020 until today. Metalama.Framework, our high-level meta-programming framework featuring aspect-oriented programming for the masses, acts as a plug-in to Metalama.Compiler at compile time, and as a plug-in of the vanilla Roslyn at design time when it runs under the IDE.

We invested a significant amount of effort into this fork – probably more than six months of real compiler professionals’ time. Initially, we were hesitant to make it publicly available because we instinctively wanted to protect our work. But in the meantime, we realized that our real value was not in opening Roslyn for code modifications, but in making meta-programming simple and accessible for all developers, without requiring in-depth compiler knowledge. Indeed, we now estimate that creating aspects with Metalama.Framework is two orders of magnitude simpler than doing that directly with the Roslyn API. Not surprisingly, the implementation of Metalama.Framework was also much more complex and demanding than the modifications we made to Metalama.Compiler, and our fears that someone is just going to “copy” us faded when we realized that just stabilizing our T# template language took us one year of hard work.

Our Vision with Metalama Compiler

Our initial vision with Metalama.Compiler was to support source transformers in addition to the existing Roslyn extension points, and to address all issues that would arise as a result of this feature: mapping of PDBs, mapping of diagnostics, interaction of this feature with analyzers and source generators, and so on. This vision is now mostly achieved, and we consider Metalama.Compiler as a stable project. We don’t have plans for significant new features at the moment, and if we will have, they will always be features that support our main product, Metalama.

Some areas may be under-tested at the moment and will require more attention, notably the interactions with source generators.

We plan to continue merging changes originated from the Roslyn team at Microsoft. We do this whenever there is a new stable release of Roslyn. We don’t plan to merge any prerelease changes.

Technical Overview

This fork extends the capabilities of analyzer projects and allows them to execute arbitrary transformations of source code during compilation via the ISourceTransformer interface from the Metalama.Compiler.Sdk package. Source transformers can replace entire syntax trees in the compilation. They can also add managed resources.

As an illustration, here is the typical skeleton of a source transformer:

usingMetalama.Compiler;usingMicrosoft.CodeAnalysis;usingMicrosoft.CodeAnalysis.CSharp;usingMicrosoft.CodeAnalysis.CSharp.Syntax;[Transformer]publicclassMySourceTransformer:ISourceTransformer{publicvoidExecute(TransformerContextcontext){varrewriter=newRewriter();foreach(vartreeincompilation.SyntaxTrees){context.ReplaceSyntaxTree(tree,tree.WithRootAndOptions(rewriter.Visit(tree.GetRoot()),tree.Options));}}classRewriter:CSharpSyntaxRewriter{// TODO: Implement transformations.}}

By default, errors and warnings are reported on the source code, and PDB files map the MSIL binary code to the source code as well, so that debugging and breakpoints work as usual. It is possible to toggle that behavior and debug the transformed code by setting some MSBuild properties. The ability to map diagnostics and PDBs back to the source code is by far the most complex feature of Metalama.Compiler.

When there are multiple source transformers in a project, they must be deterministically ordered. One way to order transformers is to use the TransformerOrderAttribute assembly-level custom attribute. A second way is to define the MetalamaCompilerTransformerOrder MSBuild property.

By default, analyzers run after all source transformers. This allows these analyzers to see the final code. However, some analyzers, for instance, the ones checking formatting, need to see the source code. To move the execution of an analyzer before the source transformers, use the MetalamaSourceOnlyAnalyzers MSBuild property.

Metalama.Compiler only covers the compilation use case. It does not cover other Roslyn use cases such as scripting or design-time. The Metalama.Compiler.Sdk package references the vanilla Microsoft.CodeAnalysis.CSharp package, not the forked versions, which makes it possible to have analyzers, diagnostic suppressors, source generators and source transformers in the same project. Source transformers won’t be loaded at design time when the analyzer assembly will be loaded, but the other assets will load successfully.

flowchart BT YourProject --> Metalama.Compiler.Sdk Metalama.Compiler.Sdk --> Microsoft.CodeAnalysis Metalama.Compiler.Sdk --> Metalama.Microsoft.CodeAnalysis subgraph IDE Microsoft.CodeAnalysis end subgraph Compile-Time Metalama.Microsoft.CodeAnalysis end Microsoft.CodeAnalysis["`_vanilla_ Microsoft.CodeAnalysis`"] Metalama.Microsoft.CodeAnalysis["`_forked_ Microsoft.CodeAnalysis`"]

Please note that Metalama.Compiler only works for C#. There is no plan to support Visual Basic.

For further details, see the project home on GitHub and the API documentation.

Who Should Use Metalama Compiler?

Due to the high complexity and efforts involved in achieving anything significant in source code transformation, we believe that building a source transformer is not for everyone. Metalama Compiler is for researchers and framework developers. However, if you are an application developer, and your job is to deliver business features, then you should probably think more than twice before embarking on the source transformation journey.

The problem is that Roslyn is much too low level. For anything less trivial than making all public methods virtual, you will spend days catering for details that are already handled by a high-level meta-programming framework like Metalama.Framework.

For instance, one significant difference in the design philosophies of Roslyn and Metalama Framework is that Roslyn is compiler sympathetic while Metalama Framework is developer sympathetic. Roslyn exposes various extensibility APIs such as analyzers, diagnostic suppressors, source generators or code fix providers. If you want to implement one aspect directly using these Roslyn APIs, you will need to integrate with all these APIs, which are all their own entry points and have very little integration. However, with Metalama Framework, you implement one aspect class (one entry point) and have access to all the Roslyn features from the same place: reporting or suppressing diagnostics, generating source code or suggesting code fixes.

If you encounter code transformations not supported by Metalama.Framework, your initial response should be to consider the following: firstly, whether there is a supported method to achieve the same result; secondly, if it’s possible to forgo the feature; and thirdly, to construct your Roslyn-level code transformation using Metalama.Framework.Sdk instead of Metalama.Compiler.Sdk. Utilizing Metalama.Compiler.Sdk allows your low-level code to benefit from all the features of Metalama.Framework, letting you focus solely on the code transformation rather than the entire scaffolding.

However, if you wish to construct another aspect-oriented framework, you can certainly build it on top of Metalama.Compiler. It may be an intellectually stimulating task and we wish you the best of luck.

Contributing

You can contribute by reporting bugs, submitting feature requests to the project’s issue tracker, or by proposing pull requests. Both pull requests and feature requests should align closely with the mission of Metalama.Compiler, which is to make the compiler open for code modification in an extensible way. The primary objective of this project is not to serve as a universal fork for all changes rejected by the Roslyn team.

Wrapping Up

We have made Metalama.Compiler, our beloved Roslyn fork, open-source. This project has been in development since August 2020. We hope it will prove useful to syntactic enthusiasts and other semantic (or symbolic, as the case may be) zealots.

My personal journey with meta-programming began in 2004 when I penned the first lines of PostSharp – lines that interpreted bits of IL and abstracted them into an object model. A crucial lesson learned from this journey is that programming is not merely about moving bits. It is a cognitive and social activity. We don’t write code for hardware. We don’t even write it for the compiler. The primary consumers of our code are always humans: you, the future you, your colleagues, and your future colleagues who will still be maintaining, a decade from now, the code you are currently writing. This is why we need advanced programming languages and frameworks: to enable the expression of business or scientific solutions at a level of abstraction that aligns with human understanding – not with compilers or hardware.

Bridging the abstraction gap between bits and minds: this has been our journey, starting from PostSharp and now continuing with Metalama.

When developing a source transformer, always consider the perspective of the developer who will be instructed to work with it. Creating a better programming experience is hard work, but it’s worth it. Metalama Compiler stands as the latest gem in your toolkit.

Metalama Source Code Available

$
0
0

We recently announced the open-sourcing of Metalama.Compiler, our Roslyn fork. Today, we are excited to announce that the source code of Metalama.Framework is now publicly accessible on GitHub under a proprietary source-available license. Additionally, all extensions and aspects built on top of Metalama.Framework have been open-sourced since their inception.

It is important to note that “source-available” does not equate to “open source” as defined by the Open Source Initiative (OSI). If you need more features than those provided by Metalama Free, you will still need to acquire a license for Metalama.

With this recent release, Metalama becomes as open as is commercially viable for a product of its kind. As Candide would have said, “All is for the best in the best of all possible worlds”, while riding his alpaca in El Dorado.

Benefits for All Users

We have made over 99% of Metalama’s source code available under a license that permits the use of the source code for reference and troubleshooting. This level of accessibility offers significant benefits to all users.

First, it simplifies the debugging and troubleshooting of compile-time code. Thanks to Source Link, users will soon be able to step into Metalama’s source code (once we publish the symbol packages), enhancing their understanding of what’s happening.

Second, the release of the source code fosters trust and transparency. When Metalama becomes a critical part of your build, it’s essential to ensure that it is professionally built and free of malicious code. Now, everyone can understand how the software works, verify the absence of backdoors, and scan the codebase for security vulnerabilities.

Furthermore, for those interested in learning, access to the source code can provide valuable insights into compiler extensibility design and coding practices.

Source Code Subscription

As previously mentioned, the standard Metalama license allows you to use the source code for reference and troubleshooting, but it does not permit modification or building of the source code. If you wish to modify the source code and build it, you must acquire the Metalama Source Code Subscription. This subscription extends your rights on the source code and grants you access to the remaining 1% that has not been publicly released.

The source code subscription provides your team with an additional level of risk mitigation. Even if we stop supporting the software or go out of business, you can still maintain the code while it remains critical to your team.

The source code subscription also qualifies you for dedicated support in setting up a build environment for Metalama.

Unlike traditional escrow agreements, our source code subscription enables you to test your ability to build before the occurrence of an adverse event triggering the release of the source code, and without the hassle of an intermediate party.

Summary

In conclusion, our decision to release the source code of Metalama aims to enhance transparency, support a superior developer experience, and foster greater trust. We understand that for many teams, choosing to use Metalama represents a significant leap of faith. Numerous companies have been using PostSharp for a decade with teams of hundreds of developers spread across multiple continents. We are grateful for this trust and hope to continue earning it with Metalama.

Viewing all 419 articles
Browse latest View live