Developing for 2005 using VS2008!

Posted by Vincent Grondin on Geeks with Blogs See other posts from Geeks with Blogs or by Vincent Grondin
Published on Sat, 24 Apr 2010 16:43:08 GMT Indexed on 2010/04/24 22:53 UTC
Read the original article Hit count: 330

Filed under:
 
I joined a fairly large project recently and it has a particularity… Once finished, everything has to be sent to the client under VS2005 using VB.Net and can target either framework 2.0 or 3.0… A long time ago, the decision to use VS2008 and to target framework 3.0 was taken but people knew they would need to establish a few rules to ensure that each dev would use VS2008 as if it was VS2005… Why is that so? Well simply because the compiler in VS2005 is different from the compiler inside VS2008…  I thought it might be a good idea to note the things that you cannot use in VS2008 if you plan on going back to VS2005. Who knows, this might save someone the headache of going over all their code to fix errors…
-        Do not use LinQ keywords (from, in, select, orderby…).
 
-        Do not use LinQ standard operators under the form of extension methods.
 
-        Do not use type inference (in VB.Net you can switch it OFF in each project properties).
o   This means you cannot use XML Literals.
 
-        Do not use nullable types under the following declarative form:    Dim myInt as Integer? But using:   Dim myInt as Nullable(Of Integer)     is perfectly fine.
 
-        Do not test nullable types with     Is Nothing    use    myInt.HasValue     instead.
 
-        Do not use Lambda expressions (there is no Lambda statements in VB9) so you cannot use the keyword “Function”.
 
-        Pay attention not to use relaxed delegates because this one is easy to miss in VS2008
 
-        Do not use Object Initializers
 
-        Do not use the “ternary If operator” … not the IIf method but this one     If(confition, truepart, falsepart).
 
As a side note, I talked about not using LinQ keyword nor the extension methods but, this doesn’t mean not to use LinQ in this scenario. LinQ is perfectly accessible from inside VS2005. All you need to do is reference System.Core, use namespace System.Linq and use class “Enumerable” as a helper class… This is one of the many classes containing various methods that VS2008 sees as extensions. The trick is you can use them too! Simply remember that the first parameter of the method is the object you want to query on and then pass in the other parameters needed…
That’s pretty much all I see but I could have missed a few… If you know other things that are specific to the VS2008 compiler and which do not work under VS2005, feel free to leave a comment and I’ll modify my list accordingly (and notify our team here…) !
Happy coding all!

© Geeks with Blogs or respective owner