开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜