Get VS to highlight all .Net 3.5 SP1 method calls

ε祈祈猫儿з 提交于 2019-12-12 18:20:09

问题


There are a bunch of new APIs in .Net 3.5 SP1.

Short of uninstalling .Net 3.5 SP1 (or doing dev on a VM), is there a way I can get VS 2008 to target .Net 3.5(RC) as opposed to .Net 3.5 SP1?

Is there a way I can get it to issue a warning when there is an API not supported in 3.5 SP1 which is being invoked?

Similar question: Find code that depends on .NET 3.5 SP1


回答1:


This actually has a surprisingly tricky answer.

First of all, to get this functionality that is outline in the following post you will need either the latest version of fxcop or VS 2008 SP1.

Once you have that installed there is a new rule (in VS 2008 Team System) called Portability Rules -> Use only API from targeted framework.

But that is not enough

Fxcop is currently shipping with dodgy wpf rules:

Quote from the last line in the above post:

It seems like there are bugs in this because it didn't complain when I referenced IEditableCollectionView which was added in 3.5 SP1. As a matter of fact, it seems like "C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Repository\Compatibility\Desktop3.5SP1.xml" doesn't list ANY of the new WPF assembly members.

Andrew, thanks for the feedback. You are correct, there is a bug. The data for WPF 3.5 SP1 is included, it's just listed under 3.0 SP2. However, the 'Priority' attribute for this file and 2.0 SP2 is incorrect. I've forwarded this information on to my old team, in meantime, a workaround is to manually change these files; for Desktop3.0SP2.xml change the priority from '3020' to '3520' and for Desktop2.0SP2.xml change the priority from '3015' to '3515'.

So you will need to crack open cmd in admin and fix up those files if you want this to work.

Once that is done, it seems to work fine.



来源:https://stackoverflow.com/questions/1030356/get-vs-to-highlight-all-net-3-5-sp1-method-calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!