3

I'm installing Visual Studio 2017 to play around with some of the new features, in my case the new language features for tuples.

Use Case

My colleagues are using VS2015, while I test out VS2017. I want to take some existing libraries where we return objects of Tuple<?,?> and rewrite a couple of them to test it out etc. Obviously I will be committing code (even though it is in test) back to our git dev branches (TFS).

Question

Is there a compiler directive that I can use to detect the version of C# currently in operation? example like #CSHARP_VERSION_7 that I can wrap around my rewritten methods, so when my colleagues merge back in (dev) my new C# 7.0 tuple methods wont cause compilation issues?

FYI, I have read the following:

Detect the C# version at compile time

http://csharpindepth.com/Articles/Chapter1/Versions.aspx

Community
  • 1
  • 1
garfbradaz
  • 3,424
  • 7
  • 43
  • 70
  • 1
    Whats wrong with the solutions outlined in your references ? Just define the constant in VS.net Debug settings and your problem is solved. – PhillipH Feb 10 '17 at 11:54
  • I'd say your best bet is to decide together with your colleagues on which C# version to use. You can use an older C# version on VS2017 I reckon. – Bart Friederichs Feb 10 '17 at 11:55
  • Isnt it something like CSHARP7 ? – BugFinder Feb 10 '17 at 11:57
  • @PhillipH: Thanks for taking the time to comment - I was thinking of defining my own, just wanted to check there weren't any MS ones before (dry and all that ;) ) – garfbradaz Feb 10 '17 at 11:58
  • Just curious, any reason your doing this in a dev branch and not just creating a new one off of them for testing purposes? You could find that you don't want the changes and need to remove them anyway. – Hack Feb 10 '17 at 12:01

0 Answers0