This project is read-only.

"this" argument modifier not shown for extension methods


Extension methods should show the "this" modifier in front of their first argument. Currently, this modifier does not appear in Sandcastle documentation, nor any other indication that a method is an extension method.
This applies to Sandcastle 2.4.10520 with SHFB

file attachments


SelormeyPaul wrote Aug 27, 2008 at 2:34 AM

Please can you illustrate what you mean? Also, please try to first use the forum to post problems so that it could be discussed.

davedev wrote Aug 27, 2008 at 5:21 AM

If you create a custom C# 3.0 extension method it's not documented as one. What should look like the following in the C# Syntax block:

public static string ExtensionMethod(
this TestClass obj

incorrectly looks like the following:

public static string ExtensionMethod(
TestClass obj

It appears to be an issue with Sandcastle since the MRefBuilder tool does not provide any additional information in the reflection file for extension methods, and presumably Sandcastle's XSLT doesn't document extension methods as being "extensions" either.

cnahr wrote Aug 30, 2008 at 2:49 PM

Sorry, I thought the issue was fairly obvious. There isn't really anything to discuss here, either -- it's simply a small bug in the current Sandcastle version.

Dave's example is exactly correct. You can also see the expected output in the MSDN Library documentation for extension methods, such as System.Linq.Enumerable.

EWoodruff wrote Dec 18, 2008 at 6:58 PM

It turns out it's a two part problem. To get the Syntax section to show the "this" reference, you must tell MRefBuilder not to rip the ExtensionAttribute by modifying its attribute filter in MRefBuilder.config. The other part is to modify the transformations so that they include the extension method usage note and (plus add the resource items to Hana and Prototype). See the attached fix file. I'll open an issue in Sandcastle Styles so that we can fix it there too.

@cnahr: Even with the Sandcastle fix SHFB will still rip the attribute unless you set the DocumentAttributes property to true. This has been fixed for the next release.

wrote Dec 18, 2008 at 6:58 PM

wrote Dec 18, 2008 at 6:58 PM

wrote Jan 19, 2009 at 11:36 AM

wrote Feb 22, 2013 at 1:40 AM