S h o r t S t o r i e s

// Tales from software development

StyleCop custom rules – IntProperty problem

with 3 comments

IntProperty problem

I’ve just spent a day trying to work out why a StyleCop custom rule that I’m writing was throwing exceptions in the Apply() method when I tried to save its settings using the StyleCop Settings Editor.

A System.ArgumentException was thrown whenever I tried to create a new instance of an IntProperty with the following error message:

The property container does not contain a property descriptor for the <property-name> property.

The property was correctly defined in the rules xml file, as documented in the ‘Adding Custom Rule Settings’ topic of the SDK help file, using an IntProperty element under the Properties element. I began to suspect that there was an error in the StyleCop framework and that it wasn’t extracting the property definition from the rules xml.

When I temporarily changed the property type to a StringProperty and reran my tests everything worked as expected. So, the StyleCop framework was correctly extracting StringProperty elements but not IntProperty elements.

IntegerProperty element

On a whim I tried coding the property using IntegerProperty as the element name. And everything worked as expected.

So, the problem is simply that the documentation is wrong. An integer property is defined in the rules xml file using an IntegerProperty element not as an IntProperty element as the SDK help file indicates.


Written by Sea Monkey

December 31, 2008 at 2:00 pm

Posted in Development

Tagged with

3 Responses

Subscribe to comments with RSS.

  1. THANK YOU! After struggling through the outdated SDK help file I was to the same point you were. This post saved me A LOT of time.

    Vance Kessler

    September 4, 2009 at 7:56 pm

    • Thanks man !! I spent half day to find out the reason.


      September 2, 2011 at 10:18 pm

  2. Thank you 🙂


    February 29, 2012 at 8:17 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: