Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. What Version Is My C# Compiler?

What Version Is My C# Compiler?

Scheduled Pinned Locked Moved The Weird and The Wonderful
questioncsharpvisual-studiodata-structureshelp
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David A Gray
    wrote on last edited by
    #1

    I ran across a Stack Overflow post that stated that C# 7.3 supports a new feature in which I am keenly interested. The obvious next question is whether I have C# 7.3, and how do I find out? The answer given elsewhere on SO works great on the dedicated C# compiler, but falls short on the new Roslyn compiler. The new command, along with an example of its output from my installation, follows.

    C:\Users\DAG 2018/08/13 20:21:18.28>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe" /langversion:?
    Supported language versions:
    default
    1
    2
    3
    4
    5
    6
    7.0 (default)
    7.1
    7.2
    7.3 (latest)
    latest

    C:\Users\DAG 2018/08/13 20:21:31.33>

    David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting

    Richard DeemingR 1 Reply Last reply
    0
    • D David A Gray

      I ran across a Stack Overflow post that stated that C# 7.3 supports a new feature in which I am keenly interested. The obvious next question is whether I have C# 7.3, and how do I find out? The answer given elsewhere on SO works great on the dedicated C# compiler, but falls short on the new Roslyn compiler. The new command, along with an example of its output from my installation, follows.

      C:\Users\DAG 2018/08/13 20:21:18.28>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe" /langversion:?
      Supported language versions:
      default
      1
      2
      3
      4
      5
      6
      7.0 (default)
      7.1
      7.2
      7.3 (latest)
      latest

      C:\Users\DAG 2018/08/13 20:21:31.33>

      David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      That output looks like the command works as expected. What were you expecting to see? :confused: Your compiler supports C# 7.3, but defaults to 7.0. To turn on 7.3, you need to change the advanced build settings. Open the properties of your project, select the "Build" tab, click the "Advanced" button, and select the language version you want. NB: For some bizarre reason, you need to change the version separately for each build configuration. 4 ways to enable the latest C# features - Meziantou's blog[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      D 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        That output looks like the command works as expected. What were you expecting to see? :confused: Your compiler supports C# 7.3, but defaults to 7.0. To turn on 7.3, you need to change the advanced build settings. Open the properties of your project, select the "Build" tab, click the "Advanced" button, and select the language version you want. NB: For some bizarre reason, you need to change the version separately for each build configuration. 4 ways to enable the latest C# features - Meziantou's blog[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        D Offline
        D Offline
        David A Gray
        wrote on last edited by
        #3

        My point is that the instructions in the SO post, [which version of C# am I using - Stack Overflow](https://stackoverflow.com/questions/19532942/which-version-of-c-sharp-am-i-using), which I forgot to cite, imply that it's in the general help message displayed when you pass the compiler "/?" to display the general help message. While that command yields lots of useful tidbits, you must amplify it a bit to get the list of supported C# language versions. Nevertheless, your reply called to my attention something which I hadn't noticed, which is that the default version in my installation is 7.0, not 7.3, as at first appeared to be the case. Thanks for the additional tidbits about how to override that. Of the four ways mentioned, the one that calls to me is the properties file, since that supports overriding all sorts of default values for every project. Though I haven't dug into the global property sheets for C#, I've made extensive changes to my C++ settings.

        David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting

        N 1 Reply Last reply
        0
        • D David A Gray

          My point is that the instructions in the SO post, [which version of C# am I using - Stack Overflow](https://stackoverflow.com/questions/19532942/which-version-of-c-sharp-am-i-using), which I forgot to cite, imply that it's in the general help message displayed when you pass the compiler "/?" to display the general help message. While that command yields lots of useful tidbits, you must amplify it a bit to get the list of supported C# language versions. Nevertheless, your reply called to my attention something which I hadn't noticed, which is that the default version in my installation is 7.0, not 7.3, as at first appeared to be the case. Thanks for the additional tidbits about how to override that. Of the four ways mentioned, the one that calls to me is the properties file, since that supports overriding all sorts of default values for every project. Though I haven't dug into the global property sheets for C#, I've made extensive changes to my C++ settings.

          David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          I never got that too, why not default to the latest stable release?

          Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

          N D Richard DeemingR 3 Replies Last reply
          0
          • N Nish Nishant

            I never got that too, why not default to the latest stable release?

            Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #5

            Nish Nishant wrote:

            why not default to the latest stable release?

            If it was that easy... everyone could do it :rolleyes: :rolleyes: :laugh: :laugh:

            M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

            1 Reply Last reply
            0
            • N Nish Nishant

              I never got that too, why not default to the latest stable release?

              Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

              D Offline
              D Offline
              David A Gray
              wrote on last edited by
              #6

              That's exactly what I expected it to do. However, I can understand some motivation for setting it to the last whole version.

              David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting

              1 Reply Last reply
              0
              • N Nish Nishant

                I never got that too, why not default to the latest stable release?

                Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #7

                I think the idea is to avoid breaking previously-compiling code unless you ask it to. :) (I haven't seen any C# 7.0 code that would be broken by the 7.3 compiler; but it's always best to CYA.)


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                N 1 Reply Last reply
                0
                • Richard DeemingR Richard Deeming

                  I think the idea is to avoid breaking previously-compiling code unless you ask it to. :) (I haven't seen any C# 7.0 code that would be broken by the 7.3 compiler; but it's always best to CYA.)


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  Yeah, but Visual Studio 2017 defaults to 7.0 for new projects too.

                  Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

                  Richard DeemingR 1 Reply Last reply
                  0
                  • N Nish Nishant

                    Yeah, but Visual Studio 2017 defaults to 7.0 for new projects too.

                    Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

                    Richard DeemingR Offline
                    Richard DeemingR Offline
                    Richard Deeming
                    wrote on last edited by
                    #9

                    I agree, it's annoying. You can apparently override it by putting a magic file in a directory somewhere above your project: Customize your build - Visual Studio | Microsoft Docs[^]

                    <Project>
                    <PropertyGroup>
                    <LangVersion>latest</LangVersion>
                    </PropertyGroup>
                    </Project>

                    But I don't like that solution. As soon as you share your project with someone who doesn't have the magic file, they'll start getting compiler errors for all the new features.


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                    N 1 Reply Last reply
                    0
                    • Richard DeemingR Richard Deeming

                      I agree, it's annoying. You can apparently override it by putting a magic file in a directory somewhere above your project: Customize your build - Visual Studio | Microsoft Docs[^]

                      <Project>
                      <PropertyGroup>
                      <LangVersion>latest</LangVersion>
                      </PropertyGroup>
                      </Project>

                      But I don't like that solution. As soon as you share your project with someone who doesn't have the magic file, they'll start getting compiler errors for all the new features.


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      N Offline
                      N Offline
                      Nish Nishant
                      wrote on last edited by
                      #10

                      Thanks, good to know.

                      Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups