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.

Difference between C# compiler version and language version的更多相关文章

  1. swift 第三方库迁移错误解决“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choo

    先看看错误提示 这里Alamofire库报错,原因打开工程会Xcode会提示你覆盖到最新的3.0版本.但是仍然有些框架会出现一些问题 解决办法: 选择Pods - ReactiveCocoa - Sw ...

  2. “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift

    使用cocopod导入第三方swift包后,编译报以下错误: The "Swift Language Version" (SWIFT_VERSION) build setting ...

  3. What is the difference between apache tomcat deployer and core version? - Stack Overflow

    java - What is the difference between apache tomcat deployer and core version? - Stack Overflowhttps ...

  4. swift语言版本选择 - 解决XCode报错:The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported valu

    转发链接:https://blog.csdn.net/nathan1987_/article/details/79757368 The “Swift Language Version” (SWIFT_ ...

  5. 解决linux下javac -version和java -version版本显示不一致

    解决linux下javac -version和java -version版本显示不一致 [javascript] view plaincopy [root@localhost usr]# $JAVA_ ...

  6. 解决maven web项目Cannot detect Web Project version. Please specify version of Web Project through...的错误

    前面已经创建maven web工程,但是问题来了,创建maven web工程之后会出现如下的错误,在pom.xml文件头部 有以下的错误 Description Resource Path Locat ...

  7. 解决Maven web 项目 Cannot detect Web Project version. Please specify version of Web Project through ... 的错误

    创建maven项目的时候,maven文件头报错: Cannot detect Web Project version. Please specify version of Web Project th ...

  8. nginx的Mainline version、Stable version、Legacy version的版本区别

    nginx的Mainline version.Stable version.Legacy version的版本区别 创建时间:2014-01-16 10:30:37最后修改:2014-09-23 20 ...

  9. /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version`

    问题及分析 今天做项目的时候,执行pod update报了如下错误信息: /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapo ...

随机推荐

  1. RabbitMQ的基本概念与原理(一)

      1.什么是MQ? MQ全称为Message Queue, 顾名思义,即消息队列,它是一种应用程序对应用程序的通信方法.MQ是消费-生产者模型的一个典型的代表,生产者不断的往消息队列中不断写入消息, ...

  2. css 之内容溢出滚动,隐藏滚动条(解决火狐浏览隐藏不了滚动条问题)

    解决火狐浏览隐藏不了滚动条问题 1.里层容器的width多17px,外层容器溢出隐藏,能兼容各个浏览器 .outContainer { width:350px; height:300px; overf ...

  3. php连接docker运行的mysql,显示(HY000/2002): Connection refused的解决办法

    php要连接docker中运行的mysql是不能用localhost, 127.0.0.1来连接的,因为每个docker运行容器的localhost 127.0.0.1都是自己容器本身,不是mysql ...

  4. 03_Redis_String命令

    一:Redis命令---String命令:Redis 字符串数据类型的相关命令用于管理 redis 字符串值 字符串类型是Redis中最为基础.常用的数据存储类型,字符串在Redis中是二进制安全的, ...

  5. 一图一知-NPM&YARN常用命令

  6. 关于SendMessage和PostMessage的理解的例子

    对于SendMessage 和 PostMessage 平时口头的解释是 SendMessage 发送消息后等待返回, PostMessage 发送消息后立即返回 . 但是这样解释还是不具体,什么叫等 ...

  7. pip报错以及指向错误

    在终端中输入无论是pip3 -V或是pip -V都指向python3 如下图所示: 然后在卸载或更新pip 时都出现了报错: 就是卸载也卸不了更新也更不了 解决报错: Traceback (most ...

  8. tsung报告中Transactions Statistics缺失问题

    长时间没有做性能测试,最近在使用tsung进行性能测试时,修改tsung自带的范例脚本后,运行查看结果时,发现测试报告中transactions  statistics缺失,刚开始一直以为是监控中的配 ...

  9. ftp定时下载指定目录或文件脚本

    #! /bin/bash rpm -qa lftp &>/dev/null || yum install -y lftp lftp 160.106.0.34 << EOF c ...

  10. Mysql中用exists代替in

         exists对外表用loop逐条查询,每次查询都会查看exists的条件语句,当 exists里的条件语句能够返回记录行时(无论记录行是的多少,只要能返回),条件就为真,返回当前loop到的 ...