views:

27

answers:

2

Hi, 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?

+1  A: 

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.

Peter
A: 

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

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

what i would like is that inside override ProblemCollection Check(member m)

I can check: if m == MethodA { Assert m makes use of C.B, assigning B the value of D

how can I do this?

Josh