Does Metalama only support attributes?
I navigated in all Metalama documentation, but I want to override a method for all types that inherit from
BusinessException
.
I don't want to use attributes because for my use case it's more natural to extend from a class.3 Replies
The easiest way to achieve that is to add the
[Inheritable]
attribute (documentation: https://doc.metalama.net/conceptual/aspects/aspect-inheritance) to the aspect. Here is an example: https://try.metalama.net/#N4IgZiBcDaoHZRABQE4HsDmKCGBbAdAMYDOIANCIYgK7ECWcGABALICmALtgDZ7b4AxHLjYB3NCgDW+AILEADm0IdiAbgA6cWg2bsuvXPyF4xE6QGE0AEzYa4m6AEk4ACzYo6XAEbc2AXU1CXmJiJgAZTBlubhkODg8vag42SCYAFQBPRTlFZU1gTSYipnlqHzpCJjQAN3cPGyZqtDorJgAhajpuKxylDgAKR17lDq6bFAAeRwA5EytMxQA+JkSx9wBKQuKCuGK9pjAJNmxCFyZ+6uwUJhEOF2smBhXO7vd8NKuMTnw9e6tiTa7fZFHbA4GrV4oWRWaoVNj4ADytRQ9TY-VufzITDgJjQYH6EQw63WdjBTAAvlsipT7ECitA0mxcPJeMkAnSmFYMjjcBUAPzhTD9QF7UFgyxwYhoXz4ADqHmSYQYaIAJOoQABRODJDyMG6cP5MYC3fgfFBfDg-A3Wcn4dUkzRU-YoTjUFC7E34VBoQhsNhWYWk4o0mkOQlRbjs7BeYjxE4cJhBbAhdraOBsEIagAevvkHDoaF2qWzufzhfyTqaLXaybY5mCxF+1mFRopmlDcCTKYlhBdyQ69HTmZzbDzBaLqcHGeIJdHZdpYqKVdaABF3HRalZ68nG9aA+tWyHyCBJIgOCByX5yUAWow, incredibly helpful, thanks!
There's also a video here: https://doc.metalama.net/videos/fabrics-and-inheritance