Tool for backwards compatibility for the C#/.NET API? [closed]

∥☆過路亽.° 提交于 2019-12-17 17:42:17

问题


I found this tool, http://sab39.netreach.com/Software/Japitools/JDK-Results/46/, which checks for backwards compatibility between different versions of APIs for Java using javadoc.

Is there an tool equivalent to this one for C#/.NET?

Here is an example of a comparison between JDK 1.5 and JDK 6 APIs using this tool: http://www.kaffe.org/~stuart/japi/htmlout/h-jdk15-jdk6


回答1:


  • ApiChange does take a set of "old" assemblies and a set of "new" assemblies which are diffed for potentially breaking Api changes:

    ApiChange -diff -old HelloWorldV1.dll -new HelloWorldV2.dll

  • LibCheck allows you to compare two versions of an assembly and determine the differences. The tool reports the differences as a combination of "removed" and "added" APIs:

    LibCheck -store HelloWorld.dll 1.0 -full C:\HelloWorldV1\
    LibCheck -store HelloWorld.dll 2.0 -full C:\HelloWorldV2\
    LibCheck -compare 1.0 2.0

See also "Working with LibCheck", "Highlight Public API Differences Between Assembly Revisions" and "Api Diff Between Assemblies" articles.




回答2:


I haven't tried the Java tool you linked to, but NDepend has some powerful tools for comparing two sets of binaries and highlighting any differences.




回答3:


I haven't tested it, but this library https://github.com/tunnelvisionlabs/dotnet-compatibility seems to provide what you'd want.

https://raw.githubusercontent.com/tunnelvisionlabs/dotnet-compatibility/master/CompatibilityCheckExample/Program.cs

IPackageRepository sourceRepository = PackageRepositoryFactory.Default.CreateRepository("https://www.nuget.org/api/v2/");
PackageManager packageManager = new PackageManager(sourceRepository, temporaryDirectory);
packageManager.PackageInstalled += HandlePackageInstalled;
packageManager.InstallPackage("Microsoft.Bcl.Immutable", SemanticVersion.Parse("1.0.34"));
packageManager.InstallPackage("System.Collections.Immutable", SemanticVersion.Parse("1.1.33-beta"));

using (PEReader referenceAssembly = new PEReader(File.OpenRead(Path.Combine(temporaryDirectory, "Microsoft.Bcl.Immutable.1.0.34", "lib", "portable-net45+win8+wp8+wpa81", "System.Collections.Immutable.dll"))))
{
    using (PEReader newAssembly = new PEReader(File.OpenRead(Path.Combine(temporaryDirectory, "System.Collections.Immutable.1.1.33-beta", "lib", "portable-net45+win8+wp8+wpa81", "System.Collections.Immutable.dll"))))
    {
        Analyzer analyzer = new Analyzer(referenceAssembly, newAssembly, null);
        analyzer.Run();
    }
}


来源:https://stackoverflow.com/questions/2377855/tool-for-backwards-compatibility-for-the-c-net-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!