2

I was playing around with DynamicMethod and Expression Trees' Compilation (which uses DynamicMethod internally).

I then wondered if there is a way to add a custom attribute to the generated method. I googled about it, but I couldn't find a way. I know that it's possible to do using CodeDom, but I want to use DynamicMethod.

Someone mentioned Type Descriptor, but I'm not sure if it helps.

Does anyone knows a way to define custom attributes to methods generated using DynamicMethod?

1 Answer 1

8

No there is no way to set custom attributes on DynamicMethods, from MSDN:

Custom attributes are not supported on dynamic methods or their parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.