您现在的位置是:首页 > 电脑 > 

是否有编译器开关关闭在C#中的泛型支持?(Is there a compiler switch to turn off support for Generics in C#?)

2025-07-19 12:11:52
是否有编译器开关关闭在C#中的泛型支持?(Is there a compiler switch to turn off support for Generics in C#?) 我正在与一个合作伙伴合作,我们正试图将复杂的驱动程序从.ET平台移植到.ET MicroFramework。 问题是.ET MF不支持泛型,当我们尝试构建应用程序时,最后的“
是否有编译器开关关闭在C#中的泛型支持?(Is there a compiler switch to turn off support for Generics in C#?)

我正在与一个合作伙伴合作,我们正试图将复杂的驱动程序从.ET平台移植到.ET MicroFramework。

问题是.ET MF不支持泛型,当我们尝试构建应用程序时,最后的“链接”操作将退出,并显示错误代码“CLR_E_PARSER_USUPPORTED_GEERICS”。 然而,没有关于WHERE(模块,代码行)的信息。

据我们所知,没有人有意插入泛型,他们一直在仔细查看代码,以确定没有运气的问题。

所以我的问题是:有没有办法在VS2010中关闭对Generics的支持,以便编译器会标出违规行?

I am working with a partner where we are trying to move a complex driver from the .ET platform to the .ET MicroFramework.

The problem is that the .ET MF doesnt support Generics and when we try to build the application the last "link" operation exits with the error code "CLR_E_PARSER_USUPPORTED_GEERICS". There is however no information on WHERE (module, code-line).

As far as we know nobody has intentionally inserted Generics and they have been really looking over the code to identify what the problem is with no luck.

So my question is: Is there some way to turn off support for Generics in VS2010 so that the compiler will flag the offending line ?

最满意答案

有什么方法可以在VS2010中关闭对泛型的支持,以便编译器将标记违规行?

是的,但它是一个“核”选项:

using System.Collecti.Generic; class Test { static void Main() { IEnumerable<int> x = null; } }
C:\> csc /lanersion:ISO-1 \ Microsoft (R) Visual C# 2010 Compiler version 4.0.019.1 Copyright (C) Microsoft Corporation. All rights reserved. c:\(9,12): error CS1644: Feature 'generics' cannot be used because it is not part of the ISO-1 C# language specification

ISO-1开关会关闭所有不在C#1.0中的功能 ,这可能比您想要关闭的功能更多。

请注意,该开关并不打算成为“在C#2.0编译器中模拟C#1.0”开关; 如果你想运行C#1.0编译器,只需运行它。 该开关旨在识别特定版本中不存在的功能并禁止它们。

请注意,交换机也可能不会做你需要它做的一切。 它所做的就是不允许使用通用语法 。 如果您在使用泛型类型时未实际使用通用语法 ,则交换机无法捕获它。

Is there some way to turn off support for Generics in VS2010 so that the compiler will flag the offending line ?

Yes, but it is a "nuclear" option:

using System.Collecti.Generic; class Test { static void Main() { IEnumerable<int> x = null; } }
C:\> csc /lanersion:ISO-1 \ Microsoft (R) Visual C# 2010 Compiler version 4.0.019.1 Copyright (C) Microsoft Corporation. All rights reserved. c:\(9,12): error CS1644: Feature 'generics' cannot be used because it is not part of the ISO-1 C# language specification

The ISO-1 switch turns off all features that were not in C# 1.0, which might be more features than you want to turn off.

ote that the switch is not intended to be a "emulate C# 1.0 in the C# 2.0 compiler" switch; if you want to run the C# 1.0 compiler, just run it. The switch is intended to identify features that were not present in the particular version and disallow them.

ote that the switch also possibly does not do everything you need it to do. All it does is disallow uses of generic syntax. If you are using a generic type without actually using generic syntax, the switch doesn't catch it.

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/654074.html

相关标签:无
上传时间: 2023-07-28 12:52:17
留言与评论(共有 9 条评论)
本站网友 西洋参的吃法
19分钟前 发表
Is there some way to turn off support for Generics in VS2010 so that the compiler will flag the offending line ? 最满意答案 有什么方法可以在VS2010中关闭对泛型的支持
本站网友 龙栖湾温泉花园
11分钟前 发表
\> csc /lanersion
本站网友 mcse
19分钟前 发表
如果您在使用泛型类型时未实际使用通用语法
本站网友 大唐军品
0秒前 发表
没有人有意插入泛型
本站网友 怎样治疗湿疹
3分钟前 发表
只需运行它
本站网友 黄花菜的功效
2分钟前 发表
error CS1644
本站网友 北京租屋
23分钟前 发表
code-line). As far as we know nobody has intentionally inserted Generics and they have been really looking over the code to identify what the problem is with no luck. So my question is
本站网友 ip地址更改器
11分钟前 发表
据我们所知