Microsoft Contracts:程序集加载导致元数据导入警告

发布于 2024-07-24 22:57:07 字数 848 浏览 3 评论 0原文

我正在尝试学习 Microsoft Code Contracts 库,我有以下简单的功能:

internal static Engine CreateBuildEngine(Microsoft.Build.Framework.ILogger logger)
{
    Contract.Requires( logger != null );

    var engine = new Engine { DefaultToolsVersion = "3.5" };
    engine.RegisterLogger(logger);
    return engine;
}

当尝试编译它时,合同静态编译器会抛出以下警告消息:

warning : contracts: Assembly load resulted in metadata import 'Could not resolve member reference: Microsoft.Build.BuildEngine.Engine::set_DefaultToolsVersion.'

然后立即放弃(并且不会尝试进行任何进一步的合同处理)。 如果我删除设置 DefaultToolsVersion 的代码,那么合约验证器可以正常工作,但是这是毫无意义的,因为它会导致代码不正确。

我在谷歌上找不到任何提及这一点...有什么方法可以解决这个问题,或者这只是合同库中的一个错误? (诚​​然,它处于预发布状态)

谢谢

I'm trying to learn my way around the Microsoft Code Contracts libraries, and I have the following simple function:

internal static Engine CreateBuildEngine(Microsoft.Build.Framework.ILogger logger)
{
    Contract.Requires( logger != null );

    var engine = new Engine { DefaultToolsVersion = "3.5" };
    engine.RegisterLogger(logger);
    return engine;
}

When attempting to compile this, the contracts static compiler throws up the following warning message:

warning : contracts: Assembly load resulted in metadata import 'Could not resolve member reference: Microsoft.Build.BuildEngine.Engine::set_DefaultToolsVersion.'

and then promptly gives up (and doesn't attempt to do any further contract processing).
If I remove the code which sets DefaultToolsVersion then the contract verifier works correctly, however this is rather pointless as it will cause the code to be incorrect.

I can't find any mention of this on google... Is there some way that I can fix this, or is it just a bug in the contracts library? (admittedly it's in pre-release status)

Thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文