如何测试.NET组件之间的API的向后兼容性 [英] How can I test the backward compatibility of API between .net assemblies

查看:122
本文介绍了如何测试.NET组件之间的API的向后兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,提供了一个API,用于其他一些组件的装配。我需要验证API DLL的新版本仍然是用API的版本较旧旧的组件不兼容。

I have an assembly that provides an API and is used by some other assemblies. I need to verify that a newer version of API dll is still compatible with the older assemblies that were using the older version of API.

我发现一对夫妇的那问同样的问题,但目前还没有答案,这解决了我的问题:

I've found a couple of questions that ask the same, but there are no answers that resolve my problem:

  • Tool to verify compatibility of a public APIs
  • Tool for backwards compatibility for the C#/.NET API

建议的工具只能比较两个组件,并说如果在API可能重大更改,但如果最新的API确实打破了使用它的旧的装配。
我想找到一个工具或编写一个测试,将能够检查是否每一个上了年纪的DLL可以与我的新API DLL工作。

Suggested tools can only compare two assemblies and say if there are possible breaking changes in API, but not if the newest API really breaks the older assembly that uses it. I'd like to find a tool or write a test that will be able to check whether each of the older dlls can work with my new API dll.

至于在API的更多可能,我只会延长,但即使它仍然可以打破code在老年组件的变化。一些这种变化的例子可以在这里找到:

As for the changes in API more likely that I will only extend it, but even though it still can break the code in older assemblies. Some of the examples of such changes can be found here:

  • A definite guide to API-breaking changes in .NET
  • .NET: with respect to AssemblyVersion, what defines binary compatibility?

现在我看到的唯一的解决办法是编译旧组件的源$ C ​​$ C与最新的API,但我想只能用组件做到这一点,并将其添加为我的单元测试的一部分。有没有更好的办法可以处理这个问题?

For now the only solution I see is to compile the source code of the older assemblies with the newest API, but I would like to do it only with assemblies and add them as part of my unit tests. Is there any better way I can handle that?

编辑:

我在找一个工具,将能够自动验证.NET程序集之间的向后兼容性的过程。 (命令行或某些API太)

I'm looking for a tool that will be able to automate the process of verifying the backward compatibility between .net assemblies. (command line or with some api too)

推荐答案

你想要的是做一个diff和产生的重大更改一个列表。然后,你想,如果你的组件不使用任何破损的API进行搜索。您可以ApiChange工具做diff和找到它的任何受影响的用户这样做。

What you want is to do a diff and generate a the list of breaking changes. Then you want to search if of your assemblies does use any of the broken APIs. You can do this with ApiChange tool to do the diff and to find any affected users of it.

要使其更加具体。如果你已经从一个界面中删除的方法,那么你需要找到在课堂这种方法,它使用的接口方式或任何类别,它实现此方法的所有实现者和用户。

To make it more concrete. If you have removed a method from an interface then you need to find all implementers and users of this method in classes which uses the interface method or any class that does implement this method.

ApiChange可以搜索实施者和命令行上的具体方法与用户的命令-whoimplementsinterface和-whousesmethod。它不是在命令行中的自动化,但你可以直接使用ApiChange.Api.dll自动执行此查询。

ApiChange can search for implementers and users of specific methods on the command line with the commands -whoimplementsinterface and -whousesmethod. It is not automated at the command line but you can directly use the ApiChange.Api.dll to automate this queries.

EDIT1:

我只是忘了:该ApiChange工具实际上有<一个href=\"http://apichange.$c$cplex.com/wikipage?title=ShowRebuildTargets&referringTitle=Documentation\"相对=nofollow>功能你有兴趣了。它是选项

I just forgot: The ApiChange tool has actually the functionality you are interested in already. It is the option

-ShowrebuildTargets -New -old [-old2] -searchin

-ShowrebuildTargets -new -old [-old2 ] -searchin

我们做我们的,效果也不错部门使用。唯一的疑难杂症是XML智能感知文件。如果另一个目标不使用去除方法,但引用它xmlDoc中内的编译器将写一个非现有方法引用的警告。这是非常难以捕捉和将涉及解析智能感知实况的文件。但是,这是一个相当边缘情况。

We did use it in our department with good results. The only gotcha are the XML Intellisense files. If another target does not use the removed method but references it inside the XmlDoc the compiler will write a warning that a non existing method was referenced. This is quite hard to catch and would involve to parse the intellisense docu files as well. But this is quite an edge case.

这篇关于如何测试.NET组件之间的API的向后兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆