Metalama and PostSharp: Code Generation and Verification Toolkits for C#This extension supercharges your development experience with a unified UI for Metalama and PostSharp. Why Choose Metalama or PostSharp?Metalama and PostSharp equip you with the tools to construct robust and maintainable applications with less code. With these tools in your arsenal, you can:
Metalama is our flagship product, designed for the new .NET stack and built upon Roslyn. It offers full integration with Visual Studio and all its new features. PostSharp is our original product, built on MSIL rewriting. It continues to receive active maintenance and support for new versions of .NET and C#. Metalama or PostSharp: Which One to Use?For all new projects, we recommend Metalama. How Metalama Works1. Add a Package to Your ProjectAdd the 2. Develop an Aspect Class or Utilize an Open-Source OneAspects are meta-classes transforming code using simple C# templates. They can also flag warnings and errors or suggest code fixes. Here's an aspect that automatically introduces logging to a method: It may seem overly simple, because it is the most trivial example! Numerous open-source aspects are readily available on Metalama Marketplace for your usage or modification. 3a. Apply Aspects to Your Business Code One at a TimeYou can apply each aspect individually using a custom attribute. 3b. Apply Aspects in BulkOr, you can apply aspects en masse using compile-time LINQ-like code. 4. Voila! You're All Set!Upon compilation, Metalama seamlessly merges the aspect template with your business code. This process is executed on the fly, ensuring your source code remains clean and clear. Aspects can also flag errors and recommend code fixes. However, exploring this extends beyond the scope of a basic Hello, world! example. What Features Does This Extension Add?While both Metalama and PostSharp are primarily distributed as NuGet packages and don't require an IDE extension, this extension enhances the development experience with the following features: Metalama DiffQuickly compare your source code with the generated code. CodeLensGet instant hints when an aspect is influencing your code. Aspect ExplorerDiscover the aspects available in the current solution and understand their impact on your code. T# Syntax HighlightingT# is Metalama's C#-to-C# template language. It's 100% C#-compatible, but the syntax highlighting feature helps you differentiate between code running at compile time and code running at runtime. PostSharp Debugging HelperThis extension also includes a debugging helper for PostSharp-based projects. What More Can You Do With Metalama?Metalama is more than just simple aspects. It's a whole universe waiting to be explored. Validate ArchitectureYou can easily express architecture in your code and have it enforced in real time right from the editor. In this example, we don't want internals of the current namespace to be accessed from a different namespace except for tests. Report Errors and Warnings from AspectsAny aspect can report errors or warnings when a violation is detected. Suggest Code FixesAspects can provide code refactorings and attach code fix suggestions to errors and warnings. Use Generated Code From Source CodeAny code generated by an aspect is visible from Intellisense and can be used in source code. DivorceMetalama gracefully accepts when it's time to part ways and makes the breakup process as smooth as possible. With the Test Your AspectsMetalama comes with a testing framework to ensure you prove your aspects before distributing them to your team. |