Josh
Josh

Reputation: 1

How to create custom static analysis rule that checks a specific property value

I would like to use the FXCop introspection API to create a custom rule that verifies the following:

in MethodA, the code sets a property B on a static class C to value D :

void MethodA() { C.B=D; }

how can I write this? also how can I debug through a rule?

Upvotes: 0

Views: 293

Answers (1)

Peter
Peter

Reputation: 14118

Your first question isn't exactly clear to me. Is this a pattern you want to have FxCop report as a problem?

For your second question:

  • Start up your custom FxCop rules project in Visual Studio.
  • Start FxCop and add your custom FxCop rules dll (the one you built in debug configuration)
  • Now go to Tools -> Attach to Process... (ctrl alt P)
  • Choose FxCop.exe
  • Run the analysis

Visual Studio will break on the break points you have set.

I found this site to be quite extensive.

Upvotes: 1

Related Questions