Metalama Community

MC

Metalama Community

Join the community to ask questions about Metalama Community and get answers from other members.

Join

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....

Can Metalama suppress compiler errors?

Hello! I want to know if I can use Metalama in my library. The users of my library have to declare the next class with this inheritance: public class EmailAlreadyExists(string email) : BusinessException("{0} already exists")...

Eligibility rule based on target method not returning void

Typically eligibility rules I've put together are based on a specifically typed return or paramters. I can't figured out how to do this so I thought I'd ask here - how can one add an eligibility rule that excludes methods that return a void? Thanks!

Follow up question from yesterday's meetup

Now that I've had time to review what was discussed I think I can now ask the question I'd wanted to more accurately than I could at the time. This question is specifically targeted at aspects that you might create that would target a wide variety of methods. An obvious example here is logging so we'll stick with that but logically the principle would apply yo any any all general purpose aspects. We can create a straightforward
LogAttribute : OverrideMethodAspect
LogAttribute : OverrideMethodAspect
and that aspect will be applied to different methods via the dynamic? OverrideMethod . ...

Please cache licensing key rather than check every build

Every time I attempt to build an aspect today, I'm getting an error that I've got an invalid license key and that I should get one from the Metalama website, which appears to be offline. I'd like to request that the local licensing scheme be updated to support say, a three-day cache or so. In the future, if the licensing server goes offline, at least it'll work over the weekend until your team is able to resolve the issue. Thanks!...

Documentation: Bad link

At https://doc.metalama.net/conceptual/using/fabrics there's a link at the bottom titled "Configuring aspects with fabrics" pointing to https://doc.metalama.net/conceptual/using/fabrics/configuring but clicking this results in a popup indicating it 404s (visiting it manually does the same and redirects to the search page).

Can one pass state between aspects?

One can trivially pass arbitrary data between the aspect class and a template via the 'args' parameter. As Metalama cannot yet create class out of thin air, I need to modify the override method of another class to do different things based on the data captured (and fields created) on another class (where it's later going to reference this second class and do things with it). Question: Can I pass any data from the "parent" aspect into this "child" aspect at compile-time?...

Ordering Aspects

In the documentation it states: 'Aspects must be ordered using the AspectOrderAttribute assembly-level custom attribute. The order of the aspect classes in the attribute corresponds to their order of execution. using Metalama.Framework.Aspects; [assembly: AspectOrder( typeof(Aspect1), typeof(Aspect2), typeof(Aspect3))] '...

This error has me foxed

It's our old friend LAMA0001 Can't work out where it is getting Net Framework reference from....

AddAspect Refactoring

Consider the following scenario. There are two aspects that can potentially be added to a method (in this case it's logging but I think that it's actually immaterial). [LogMethod] logs a method. [TimedLogMethod] does exactly the same only adds timing as well. ...

RemoveAspectIfEligible?

Thinking out loud here. Title should actually be RemoveAspectIfPresent? Is there a case for having a RemoveAspectIfPresent<> function to add to Fabrics?...

Testing Fabrics

Short of actually creating a project that covers all of the bases that one would want to cover is there a way to test fabrics present in Metalama that I have somehow missed?

Eligibility MustNotHaveAspectOfType

I want to have intellisense show a red squiggle under and attribute if it is added to a method that already has another attribute added.
I had assumed that MustNotHaveAspectOfType would fit the bill here but it seems I'm mistaken. What should I be using? Whilst we're on that subject can that eligibility be chained in an upwards direction. So for example if I apply a [NoLog] attribute to the class can I add build eligibility to a method aspect that would pick that up.? DeclaringType seems not be an option when applied to builder in the BuildEligibility override....

Test should surely either both pass or both fail

Within the following repository (https://github.com/domsinclair/VtlSoftware.LoggingAspects) there are two tests on methods, one with and one without params. As far as I can see either both should pass or both should fail. It seems to be counter intuitive that one passes and the other fails, given the nature of the reported error.

Testing Issue

I've followed the basic instructions in the Documentation for testing Aspects (https://doc.metalama.net/conceptual/aspects/testing/aspect-testing) Starting off with something simple to hopefully make it easier. However I'm getting an Asert.Equal() failure. Could the fact that CodeRush can automatically add regions to code when it is saved be the cause of this?...

Has anyone tried the Ctrl + . refactor menu recently?

According to the documentation Invoking Ctrl + . to pull up the refactor menu should (if they are available in that context) offer you the option to add an aspect, I'm not seeing that in VS 2023 17.6.2

Is it possible to mix aspects that call different parts of a class (ie Methods and Properties)?

Pretty much as per the subject line. Consider the following scenario where one has aspects to log methods, Properties and eventually (subject to future metalama developments) Events. I would like to create fabric extension methods that would add all two / three at the same time....

Is this section of the documentation wrong?

I'm looking at the following topic (https://doc.metalama.net/conceptual/using/fabrics/adding-aspects) and in particular the second example, oddly enough because I want to establish the best way to add more than one aspect using a single fabric. Is it me or does the example not actually demonstrate what the section purports to cover?...

Why is it indicating I have compile-time code despite not?

See the screenshot - Is there some way to decorate this to make clear that nothing in the class contains compile-time only code?
No description

How do I invoke (and cast) an introduced generically typed field?

Bear with me - there's a lot going on here. Also Discord is funky about styling my code, so I'm handwriting it (pardon any typos). At a high level, let me explain where I'm trying to go and then I'll get into the issue. I want to attach an attribute to a target type that defines a type (TEntity) and another type (TEntityId) so I can use these to introduce some advice later on. I can retrieve those no problem - each is saved as an INamedType on the BuildAspect method. I then want to iterate through most of the properties of the TEntity type itself and introduce at least one field for several of them, but the type of the field depends on the type of the property itself. Again, this is set up and works fine. I save all the references to the introductions in a dictionary keyed by a reproducible mechanism to link the properties with the introduced types. Again, this works fine. My target type implements a base type which has a bunch of event callbacks in place. What I want to do is replace the last methods in those event callback chains with a method that can do operations against some or all of these introduced fields and this is where I'm having some difficulty....