Dependency Injection
In June, we have focused on the support for dependency injection. It is now possible for an aspect to use a dependency without knowing which dependency injection framework is used in the project using the aspect. The implementation of this feature is open source. It consists in a highly extensible abstraction, as well as two first implementations: one for the standard injection patterns of .NET Core (i.e. Microsoft.Extension.DependencyInjection
), the second for a classic service locator pattern (a good fit for objects that are not instantiated by the container).
Here is an example where a LogAttribute
aspect pulls a dependency of type IMessageWriter
you can see that the aspect code is very simple and does not know anything about the dependency injection pattern.
For details regarding dependency injection in Metalama, see this documentation article.
The dependency injection feature was made possible thanks to the following user stories:
- Introduce and pull parameters from constructors
- Add/remove custom attribute from aspect
- Any compile-time type can have templates
- Declarative advising is now customizable
Other features
- The test framework now supports concurrent processing on different cores.
- You can now override and introduce a finalizer.
- We have updated our compiler to Roslyn 4.2.
- 38 bug fixes and minor enhancements just in June.
What’s next
All features planned for 1.0 are now implemented, however some of these features still have some gaps. Therefore we are not code complete as we hoped last month.
Here is what is still on our to-do list:
- Gaps in existing features:
- advising operators,
- proper testing with structs and records,
- implementing generic interfaces,
- improving code generation patterns,
- getting
System.Reflection
object for declarations introduced by aspects.
- Documenting and easing the migration from PostSharp
- Licensing
Therefore we will spend most of the summer filling these gaps and improving our standard of testing.
As always, your feedback is greatly appreciated and, most likely, can have large impact on the final product. To get instant answers, the best is still to join our Slack community.
Happy meta-programming with Metalama!
-gael