c# .net 6 Using a custom attribute on a parameter. Need to read the parameters value in the attribute at runtime. I know its not possible to pass it as a argument to the attribute because its compile time, but I need an idea to overcome this problem!
wish I can do: public void MyMethod([Custom(parameter)] string parameter)
and use it like this:
[AttributeUsage(AttributeTargets.Parameter)]
public class CustomAttribute : Attribute
{
public string Description;
public CustomAttribute(string description)
{
Description = description;
}
}
P.S. I saw here: How to plug method parameters into custom attribute last answer is true?
If not, any ideas from you experienced guys?