how do i code a RemoveCallsToGCKeepAlive exception to be picked up in FxCop?
I am testing FxCop automation and want to validate it is screening and catching certain r开发者_如何学Goules. I want to make a dll that will trigger the RemoveCallsToGCKeepAlive error in FxCop.
I have the following code but it is not triggering the RemoveCallsToGCKeepAlive rule at all. what am i doing wrong?
static void Gen_RemoveCallsToGCKeepAlive(){
string str = "";
GC.KeepAlive (str);
}
how can i trip this FxCop Rule?
If you use the stand-alone FxCop, your code isn't checked for the same reason of this.
The RemoveCallsToGCKeepAlive is a Relialibity rule so FxCop doesn't support it.
UPDATE
You can use this rule in FxCop, if you copy VS2010 code analysis rules to FxCop Rules directory. For more detail, refer to my answer of this question.
精彩评论