Extension methods in MAML?

Topics: User Forum
Sep 6, 2011 at 7:23 AM


When I write a conceptual topic, is it possible to reference an extension method?



Sep 6, 2011 at 7:19 PM

Extension methods are just like any other method.  You can add links to them using the Entity References tool window which will format the MAML element correctly for you.



Sep 7, 2011 at 6:36 AM

The point is, I would like it to be displayed just like it's supposed to be used. In the compiled docs, will it be displayed as a static or as an extension method?

Sep 8, 2011 at 1:58 AM

I see you asked the same question in the Sandcastle project (http://sandcastle.codeplex.com/discussions/271588).  There isn't anything to add beyond what was said there.



Sep 8, 2011 at 9:28 AM

Do you think it is possible to write an extension to SHFB that would take the extension method link and rewrite it the way I need?

Sep 8, 2011 at 7:35 PM
Edited Sep 8, 2011 at 7:38 PM

The codeEntityReference gets converted to a referenceLink by the XSL transformations.  They, in turn, are converted to HTML by ResolveReferenceLinkComponent2.  As such, you'd end up creating a custom version of that build component.  Whether or not it could be done depends on whether the necessary context is there for it to determine whether or not it's an extension method.  It may be more trouble than it's worth given that by looking at the method topic you can tell it's an extension method and IntelliSense when using the library will clue you in too.  Another consideration is that it may be misleading or confusing to show it as "String.SomeMethod" in the documentation since SomeMethod is not really a member of the String class, it's a member of your extension class.  I think It would be best to keep that distinction clear and unambiguous which the existing behavior accomplishes.


Sep 9, 2011 at 3:10 PM

Thanks! Looks like it's a lot of trouble indeed.