Freigeben über


How to set a friendly name on an Extraction Rule

In VS2008, we changed the way custom Extraction rules, Validation rules, and web and load test Plugins return a friendly name and description.

In 2005, these were implemented as override on the abstract base class. The problem with this was that it required us to instantiate the class at design time, which we really didn't want to do for a number of reasons.

So we moved to a pretty standard (in .NET) way of doing this via attributes on the class. But the attribute names are not in the web test or load test namespace, so they are not discoverable, and our samples online are wrong (I added some wiki comments). Even the warning we give at compile time if you compile the old sample or an old rule isn't enough to figure out what attribute to use:

Warning: Member 'MyRules.MyValidationRule.RuleName' overrides obsolete member 'Microsoft.VisualStudio.TestTools.WebTesting.ValidationRule.RuleName'. Add the Obsolete attribute to 'WebAndLoadTestPluginsAndRules.CompareContextParams.RuleName'.

To set the name and description, simply add these to your class:

[System.ComponentModel.DisplayName("My Friendly Rule Name")]
[System.ComponentModel.Description("My rule description")]
public class MyValidationRule : ValidationRule

Ed.

Comments