Click or drag to resize
Sandcastle Help File Builder

XPath Reflection File Filter Plug-In

This plug-in, based on code submitted by Eyal Post, is used to filter out unwanted information from the reflection information file using XPath queries. While the project's ApiFilter property and the other properties in the Visibility category can provide the most efficient way to remove unwanted class members, they may not always meet everyone's needs. This plug-in allows you to add a set of XPath queries that will be used to search the reflection information file and remove elements that match them.

The list box at the top of the configuration dialog box shows the list of expressions to use. Click the Add button to add a new expression. The default expression on new entries is an example that removes all constructors. Use the text box at the bottom of the form to change it to an expression for your project. As you move from one entry to another, the expression is displayed in the text box for editing. Click the Delete button to delete an expression from the list.

As an example, suppose you wanted to remove all constructors from the help file without having to maintain the API filter each time you added new classes to the project. This could be accomplished by adding the following expressions to the plug-in's configuration:

  • /reflection/apis/api[contains(@id,"#ctor")]
  • /reflection/apis/api/elements/element[contains(@api,"#ctor")]
  • /reflection/apis/api[contains(@id,"#cctor")]
  • /reflection/apis/api/elements/element[contains(@api,"#cctor")]

The first two entries remove the instance constructor entries as well as the elements that appear on the member list pages. The last two remove the corresponding static constructor entries. In the following example, the inherited Object methods are removed from all sealed classes.

  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.Equals(System.Object)"]
  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.GetHashCode"]
  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.GetType"]
  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.Finalize"]
  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.MemberwiseClone"]
  • /reflection/apis/api[apidata/@subgroup="class" and typedata/@sealed="true"]/elements/element[@api="M:System.Object.ToString"]
Tip Tip

Set the project's CleanIntermediates property to false and perform a build to obtain a copy of the reflection information file. It can be found in the working folder after the build and will help you determine how to construct the necessary XPath expressions.

See Also

Other Resources