ReSharper - 条件编译 XML 注释错误

发布于 2024-10-08 10:21:23 字数 509 浏览 0 评论 0原文

如果我有以下代码...

#if PocketPC
        /// <summary>Indicates whether usage of the Windows Mobile 5.0+ GPS intermediate driver is allowed.</summary>
        private static bool allowGpsIntermediateDriver = true;

        /// <summary>Indicates whether the device detection thread is currently active.</summary>
        private static bool isDetectionThreadAlive;
#endif

...ReSharper 给出“xml 注释未放置在有效语言元素上”错误。有时这些可以用 #pragma 抑制,但大多数情况下不能。有什么办法解决这个问题吗?

If I have the following code...

#if PocketPC
        /// <summary>Indicates whether usage of the Windows Mobile 5.0+ GPS intermediate driver is allowed.</summary>
        private static bool allowGpsIntermediateDriver = true;

        /// <summary>Indicates whether the device detection thread is currently active.</summary>
        private static bool isDetectionThreadAlive;
#endif

...ReSharper gives me "xml comment is not placed on a valid language element" errors. Sometimes these can be suppressed with #pragma but mostly they can't. Is there any way around this?

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

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

发布评论

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

评论(1

怪我入戏太深 2024-10-15 10:21:23

在任何 C# 代码开始工作之前,将“#define PocketPC”放在 C# 文件的顶部。

我暂停了 Resharper,如果我不先定义它,Visual Studio 就无法使用查找引用 (shift F12) 来获取代码。

我认为这是由于 Visual Studio 无法分析定义的预处理器指令“PocketPC”,并且可能不是 Resharper 问题。

有趣的是,如果尝试使用#if DEBUG,则只有将 Visual Studio 构建配置设置为“调试”时才有效。如果将构建配置更改为Release,则会遇到同样的问题,即Visual Studio 无法理解#if DEBUG。

如果您可以在全局范围内定义该指令,那就太好了。

Put "#define PocketPC" right at the top of the C# file before any of your c# code seems to work.

I suspended Resharper, and Visual Studio can't pick up the code using find reference (shift F12) if I don't define it first.

I think this is due to the fact that Visual Studio can't analysis the defined preprocessor directives "PocketPC", and may not be a Resharper issue.

Funny thing is that if tried using #if DEBUG, that works only if you set Visual Studio build configuration to Debug. If you change the build configuration to Release, you will have the same problem where Visual Studio doesn't understand #if DEBUG.

It would be nice if you can define this directive globally.

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