Free cookie consent management tool by TermsFeed Policy Generator

Opened 12 years ago

Last modified 12 years ago

#1759 closed enhancement

Add FxCop rules to HeuristicLab — at Version 3

Reported by: abeham Owned by: abeham
Priority: medium Milestone: HeuristicLab 3.3.7
Component: General Version: 3.3.7
Keywords: Cc:

Description (last modified by abeham)

There's a tutorial on the codeanalysis blog on how to write custom rules. They note that writing custom rules is not a supported feature. However, implementing a rule doesn't seem to be that complicated (depends of course) and we might benefit a lot from having the most important rules manifested and automatically tested.

The integration into the build seems quite easy. First, the rules are written as classes deriving from BaseIntrospectionRule in an assembly. The assembly has to be placed into a convenient location in the repository. The assembly also contains an additional xml file that provides metadata on these rules. Having this, a custom ruleset needs to be created in the solution folder. This ruleset references the rules in the assembly and defines whether a certain rule is a warning or error. Finally, the ruleset can be selected in the project properties in the tab "Code Analysis" and have it checked on build. Manual integration should also be possible easily as FxCop is essentially a command line program.

Official documentation on FxCop is hardly available, but there is a good summary (PDF) available from another party.

Change History (3)

comment:1 Changed 12 years ago by abeham

  • Owner changed from swagner to abeham
  • Status changed from new to accepted

comment:2 Changed 12 years ago by abeham

r7340: added project to include FxCop rules for HeuristicLab 3.3

Note that the first test rule wasn't a particular easy idea and it's not 100% correct. I basically wanted to check if the StorableHook attribute is attached to a method and check if it's called AfterDeserialization. However, there are two hook types and they're distinguished by a property. I've not yet found out how to check that so it just assumes that any StorableHook needs to be called AfterDeserialization. This is not generally correct, but I'm pretty sure we don't have any BeforeSerialization hooks.

I've not yet added this to the trunk, but tested it briefly and it worked nicely.

comment:3 Changed 12 years ago by abeham

  • Description modified (diff)
Note: See TracTickets for help on using tickets.