zoukankan      html  css  js  c++  java
  • Difference between C# compiler version and language version

    Difference between C# compiler version and language version

     
     

    As nobody gives a good enough answer, I will have a try now.

    First, C# has its version history published by Microsoft now (coming from MVP posts obviously),

    https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history

    So you can easily see what new features are added for each new releases.

    Second, we will talk about the compiler releases, which initially were part of .NET Framework.

    Below I list a few milestones (might not be 100% correct, and some versions might be skipped),

    • csc.exe 1.0 (?) for .NET Framework 1.0 (implements C# 1.0).
    • csc.exe 2.0 (Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8745) for .NET Framework 2.0 (implements C# 2.0, as well as 1.0 for compatibility).
    • csc.exe 3.5 (Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.8763) for .NET Framework 3.5 (implements C# 3.0, and older versions).
    • csc.exe 4.0 (?) for .NET Framework 4.0 (implements C# 4.0, and older).
    • csc.exe 4.x (like Microsoft (R) Visual C# Compiler version 4.7.2053.0) for .NET Framework 4.5 and above (implements C# 5.0, and older). Note that the version numbers vary a lot (from 4.x to 12.x) based on the .NET Framework on your machine (4.5.0 to 4.7.1).

    Then Microsoft made the old csc.exe obsolete (as they were native executable), and shipped Roslyn based compiler instead (though still csc.exe). In the meantime, C# compiler is no longer part of .NET Framework, but part of VS.

    It was the same time, that C# compiler, language version, and .NET Framework are fully decoupled, so that you can easily use multi-targeting.

    • Roslyn csc.exe 1.x (?) implements C# 6.0 and older. Shipped with VS2015.
    • Roslyn csc.exe 2.x (like Microsoft (R) Visual C# Compiler version 2.4.0.62122 (ab56a4a6)) implements C# 7.x and older. Shipped with VS2017.

    Ok, enough background. Back to your questions.

    Q1: How to find out what C# version (not the compiler one, but the language one) uses VS to build my concrete project?

    Answer: You can easily see from project settings that what language version is used.

    If you don't choose an explicit version, it can automatically use the latest version supported by the csc.exe compiling the project.

    Note that @Servy commented under @DaniloCataldo's answer about the langversion switch with more details. That switch has its design goals and limitation. So for example even if you force Roslyn 2.x compiler to compile your project based on C# 4.0, the compiled result would be different from what C# 4.0 compiler does.

    Q2: Is there a strict, clear and transparent link between the C# compiler and language versions?

    Answer: Please refer to the background I described above, I think that already answered this part. There is a strict, clear and transparent link.

    Q3: Can I indicate to Visual Studio (in case of migration issues from one Studio version to another) to use different compiler version for my concrete solution?

    Answer: Duplicate to Q1.

  • 相关阅读:
    Oracle数据库测试和优化最佳实践: OTest介绍 (转)
    Oracle数据库中心双活之道:ASM vs VPLEX (转)
    awrcrt更新到2.1(重大更新)
    Oracle性能图表工具:awrcrt.sql 介绍,更新到了2.14 (2018年3月31日更新)
    java虚拟机---内存
    如何进行高效的学习
    OpenGL绘制自由落体小球
    MDA系统分析实战--图书馆管理系统
    Python爬虫实战---抓取图书馆借阅信息
    Python--urllib3库详解1
  • 原文地址:https://www.cnblogs.com/chucklu/p/11300738.html
Copyright © 2011-2022 走看看