Support for Extension Methods

3 views
Skip to first unread message

Josh Flanagan

unread,
May 6, 2009, 8:57:47 PM5/6/09
to docu-...@googlegroups.com
I would like to extend the Method type exposed by DeclaredType so that I can tell if a method is an extension method. This would be useful for 2 reason:
1) It would be nice to include the "this" prefix on the first parameter of an extension method in the output. The current templates do not do this, and I'm guessing its because that information is not available.
2) I am trying to generate a page that contains just my extension methods, so I need a way to filter all the methods on a DeclaredType.

There are a couple ways that Method could be extended to support this - I'm looking for feedback on what you think would be the best.
1) Add an IsExtensionMethod property, similar to IsPublic / IsStatic
2) Since the only way I know of to identify an extension method is by checking for the existence of the ExtensionAttribute, we could add an IEnumerable<Attribute> Attributes property to method, and leave it up to the consumer to do their own processing. This has the benefit of allowing more flexibility since there are other scenarios where knowing attributes would be helpful, at the expense of exposing more type internals, and requiring more work of the consumer.
3) Expose the entire MethodInfo off of Method so that templates have full access to all metadata. This allows maximum flexibility at the loss of abstraction.

I'm very new to the codebase, so I"m not familiar with its philosophy yet. Which of these (if any) options would best fit with the Docu vision? I'm happy to do the work if given some direction.

-Josh
Reply all
Reply to author
Forward
0 new messages