.Net Framework Service Pack copmatibility check

Hello,

Is there any way for Resharper to check that C# code is copmatible with a certain service pack of a given .Net Framework version?

Here's a use case when it's needed:
The project is targeting framework: .Net Framework 2.0
The code must be compatible with .Net 2.0 SP1

Developers in many cases just use intellisense and don't look in MSDN or don't read it thoroughly enough (I mean .Net version limitation). And they can use class or method that exists only in Service Pack 2 of .Net 2.0 (becuase they have it installed on their machines)
The example of such method is WaitHandle.WaitOne(Int32 milliseconds)

I'm looking a way to prevent developers from checking in such code if there's a requirement of SPx-compatibility.

Can I achieve this with Resharper? Are there any plugins that can help?

Thanks

PS: VS 2010

6 comments
Comment actions Permalink

Hello
     There's no such compatibility check out-of-the-box. However, you can use the Structural Search and Replace feature of ReSharper to highlight such method calls as errors in the editor, which would gain more attention from developers. You can start with this blog post: http://blogs.jetbrains.com/dotnet/2010/08/highlighting-custom-patterns-with-resharper/. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Thanks for your sugsestion!
Unfortunately I don't know in advance all the possible classes and methods that are new in each SP.
Loking through MSDN for all compatibility issues doesn't seem to be a good idea.
One of solutions would be to enumerate all Framwork's classes on a given installation (fortunately, there're very few SPs released) and build a database for copmarison. But how to do such enumeration?
Maybe there's already such a difference database somewhere to obtain?

0
Comment actions Permalink

Has there been any update on this, or any other ideas? I've been burned a few times now by using method overloads that are only present in service packs for the framework. Is there a way to build a list of flagged methods? Even if I have to setup a machine with the base framework and run some kind of tool to build a list of supported methods, I'm willing to do this. I just need an easy way to identify service-pack-only methods. Thanks!

0
Comment actions Permalink

Hello Jon
     In order to build such list one could use reflection to traverse all types and methods on .NET Framework installations with and without SP and then create a diff. However, I'm not aware of any ready tools that can do this. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Thanks for the follow-up. After some digging, I found this:
http://msdn.microsoft.com/en-us/library/cc667408.aspx

It sounds like it will do exactly what I need, but sadly I only have VS Pro (not the required Premium). Is there a way to duplicate this check (CA1903) in ReSharper?

0
Comment actions Permalink

It looks like FxCop can do this, so I've just integrated it into my build process for now. It would be perfect if Resharper could warn about these errors right in the IDE though. :)

0

Please sign in to leave a comment.