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. docker 无法使用vi

    更新来源 apt-get update   安装vim apt-get install -y vim

  2. 微信小程序编译提示tabar.iconPath 文件不存在

    tabBar.list[0].iconPath 文件不存在 明明是按路径放了本地图片的,却依然显示路径不存在 需要把路径的图片转移到编译后的weapp文件中相同路径下的img文件中 本地正常路径 粘贴 ...

  3. @ComponentScan注解及其XML配置

    开发中会经常使用包扫描,只要标注了@Controller.@Service.@Repository,@Component 注解的类会自动加入到容器中,ComponentScan有注解和xml配置两种方 ...

  4. 多线程理论———— threading

    什么是线程 线程也是一种多任务编程方法,可以利用计算机多核资源完成程序的并发执行.线程又被称为轻量级的进程.线程的特征 * 线程是计算机多核分配的最小单位 * 一个进程可以包含多个线程 * 线程也是一 ...

  5. 《浏览器工作原理与实践》<06>渲染流程(下):HTML、CSS和JavaScript,是如何变成页面的?

    在上篇文章中,我们介绍了渲染流水线中的 DOM 生成.样式计算和布局三个阶段,那今天我们接着讲解渲染流水线后面的阶段. 这里还是先简单回顾下上节前三个阶段的主要内容:在 HTML 页面内容被提交给渲染 ...

  6. Django模型层:单表操作,多表操作,常用(非常用)字段和参数,Django-model进阶

    一.web应用 二.模板的导入与继承 三.静态文件相关 四.inclusion_tag:返回html片段 五.模型层 一.web应用 -s包括两个部分:web服务器+application -目前阶段 ...

  7. CHANGELOG 的实现

    项目需要写版本信息时有对除了版本号之外更详细的 changelog 的展示, 于是就需要在平时的 git commit 中进行规范, 才能自动生成CHANGELOG.md. Husky 首先本地安装 ...

  8. easyui tree选中指定节点,点击指定节点

    功能需求描述如下: A主页面,在datagrid的某行上,操作列,点击详情,Tab页面上加载B页面 B页面,左边是树tree,右边是左边树的详情列表 要求:由A页面链接到B页面,B页面的tree,默认 ...

  9. RAID 10是将RAID 1和RAID 0结合

    RAID 10是将RAID 1和RAID 0结合,它的优点是同时拥有RAID 0的超凡速度和RAID 1的数据高可靠性,但是CPU占用率同样也更高,而且磁盘的利用率比较低.由于利用了RAID 0极高的 ...

  10. 10 masterless、高可用、salt执行模块开发、sydic架构

    1.salt无master 官方文档: http://docs.saltstack.cn/topics/tutorials/quickstart.html 1.使用场景 1.在项目中使用salt,写一 ...