Visual Studio 2008 不显示任何“过时”警告

发布于 2024-07-15 12:29:15 字数 639 浏览 11 评论 0原文

重复: 为什么在调用 C# 集合属性的属性时,它们没有被标记为过时?

我刚刚使用 Visual Studio 2008 将 .NET 1.1 项目迁移到 .NET 2.0。我知道项目中存在对过时方法的引用。

但 Visual Studio 在构建后不会显示“过时”警告。 构建成功,并且仅显示来自分配了从未使用过的值的成员的 3 条警告。 当我删除这些成员时,根本没有任何警告。

我需要这些“过时”警告

警告级别为 4(最大),警告已启用。

仅举一个示例:

protected internal DataConnector()
{
    _connectionString = ConfigurationSettings.AppSettings["ProductConnectionString"];
}

所有应导致“过时”警告的引用都是对 .NET Framework 类的成员的引用。

Duplicate: Why are C# collection-properties not flagged as obsolete when calling properties on them?

I just migrated a .NET 1.1 project to .NET 2.0 using Visual Studio 2008. I know that there are references to obsolete methods in the project.

But Visual Studio does not show "obsolete"-warnings after building. The build succeeds and shows only 3 warnings from members that are assigned a value that is never used. When I remove these members there are no warnings at all.

I NEED THESE "OBSOLETE"-WARNINGS

The Warning level is 4 (maximum), Warnings are enabled.

Just one sample:

protected internal DataConnector()
{
    _connectionString = ConfigurationSettings.AppSettings["ProductConnectionString"];
}

All references that should result in an "obsolete"-warning are to members of classes of the .NET Framework.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

樱花落人离去 2024-07-22 12:29:15

调用过时方法的代码本身是否被标记为过时?

Is the code calling the obsolete method(s) itself flagged as obsolete?

反目相谮 2024-07-22 12:29:15

只是在这里尝试一下,但是在您正在引用的项目中是否使用了过时的成员,并且当您构建时它实际上并没有重建该项目? 如果可能的话,我会尝试手动构建正在使用的项目,或者只是重建整个解决方案。

Just taking a shot in the dark here, but is the usage of an obsolete member taking place in a project that you're REFERENCING, and when you're building it isn't actually rebuilding that project? If that's a possibility, I would try manually building the project where the usage is taking place, or just rebuilding the entire solution.

不顾 2024-07-22 12:29:15

确保您正在对项目进行完整构建,而不仅仅是增量构建。

Make sure you are doing a full build on the project, not just an incremental build.

偏爱你一生 2024-07-22 12:29:15

Jeff Yates 是对的,这是 为什么在调用 C# 集合属性的属性时,它们没有被标记为过时?

这是此处报告的 C# 3.5 编译器中的一个错误:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback。 aspx?FeedbackID=417159

我检查了它:将 csc.exe 命令行从输出窗口复制到 cmd 控制台。 当我将目录更改为 .NET 2.0 目录(使用 C# 2.0 编译器)时,它会显示警告。 Microsoft 知道这个错误并在 C# 4.0 中修复了它,但不会在 3.5 版本中修复它。

Jeff Yates is right, this is a duplicate to Why are C# collection-properties not flagged as obsolete when calling properties on them?

It is a bug in the C# 3.5 compiler reported here:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=417159

I checked it: copied the csc.exe commandline from the output window to a cmd-console. When I change the directory to the .NET 2.0 directory (using C# 2.0 compiler), it shows the warnings. Microsoft knows this bug and fixed it in C# 4.0 but will not fix it in the 3.5 version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文