CODE_ANALYSIS常量现在在最新版本(1.4.30903.0)中定义 - 打破变化 [英] CODE_ANALYSIS constant now defined in latest version (1.4.30903.0) - breaking change
问题描述
我们有大量代码包含对CODE_ANALYSIS常量的引用。
We have a large amount of code that contains references to the CODE_ANALYSIS constant.
此常量现在已启用Microsoft.CodeContracts.targets(即使未启用代码协定时) )。
This constant is now enabled Microsoft.CodeContracts.targets (even when code contracts are not enabled).
以下示例显示了如何在编辑器中呈现代码(在未选中CODE_ANALYSIS复选框时显示为灰色),但是在编译时代码包含"应该被忽略"行(由于CODE_ANALYSIS始终开启)
The following example shows how the code is rendered in the editor (greyed out as the CODE_ANALYSIS checkbox is unticked), however when compiled the code includes the 'SHOULD BE IGNORED' line (due to CODE_ANALYSIS being always on)
#if CODE_ANALYSIS
应该被忽略
#endif
此行为可以恢复到之前的版本吗?
有一条评论(4.0 CodeContracts.targets第53行)突出显示常量的'偷偷摸摸'设置
还动态定义CONTRACTS_FULL和CODE_ANALYSIS,否则
Also define CONTRACTS_FULL and CODE_ANALYSIS dynamically, otherwise
VS属性构建窗格选择它并可能将其持久保存到项目中
VS property build pane picks it up and may persist it into the project
设置!
推荐答案
我正在研究这个问题。我不认为在最新版本中有任何改变可能会使这种情况有所不同。你是不是确定这是这个版本中的新行为吗?我绝对同意我们在重写器
打开时定义CODE_ANALYSIS。我想我们可能从未想过人们会将if-defs放入依赖于该符号的代码中。代码分析工具建议做什么?
I'm looking into this. I don't think there were any changes that should have made this behave any differently in the latest release. Are you sure this is new behavior in this release? I definitely agree that we are defining CODE_ANALYSIS whenever the rewriter is turned on. I think we probably never figured people would put if-defs into their code that depend on that symbol. Is that something the Code Analysis tools recommend doing?
这篇关于CODE_ANALYSIS常量现在在最新版本(1.4.30903.0)中定义 - 打破变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!