Git Product home page Git Product logo

dotnet-apiport's Introduction

.NET API Portability

Note: We're in the process of deprecating API Port in favor of integrating binary analysis directly into .NET Upgrade Assistant. In the upcoming months, we're going to shutdown the backend service of API Port which will require to use the tool in offline mode. The instructions to use API Port in offline mode can be found here.

This repository contains the source code for .NET Portability Analyzer tools and dependencies.

Branch Build Status
main Build Status
dev Build Status

For a quick introduction, check out this video on Shows:

There is a Visual Studio extension available for VS 2017 and VS 2019: .NET Portability Analyzer

Using this Repository

See our contributing guide for instructions to build and run from the source code in this repo.

Sample usage to run the analysis from the command line:

./init.ps1
dotnet build src/ApiPort/ApiPort/ApiPort.csproj
dotnet bin/Debug/ApiPort/netcoreapp2.1/ApiPort.dll -- listTargets
dotnet bin/Debug/ApiPort/netcoreapp2.1/ApiPort.dll -- analyze -f Foo.dll -r HTML

If using bash for your shell, for convenience you may create an alias command adding the following to your ~/.bash_profile. Replace {dotnet-apiport-folder} with the path where you cloned the repo.

alias apiport="dotnet {dotnet-apiport-folder}/bin/Debug/ApiPort/netcoreapp2.1/ApiPort.dll"

This will allow you to use apiport globally from the command line: apiport analyze -f Foo.dll -r HTML

Documentation

Projects

Project Description
ApiPort Cross-platform console tool to access portability service
ApiPort.Vsix Visual Studio Extension
Microsoft.Fx.Portability Provides common types for API Port
Microsoft.Fx.Portability.MetadataReader Implements a dependency finder based off of System.Reflection.Metadata. The library will generate DocIds that conform to these specifications.
Microsoft.Fx.Portability.Offline Provides access to data in an offline setting so network calls are not needed
Microsoft.Fx.Portability.Reporting.Excel Provides support for an Excel spreadsheet report for ApiPort
Microsoft.Fx.Portability.Reporting.Html Provides support for an HTML report for ApiPort
Microsoft.Fx.Portability.Reporting.Json Provides support for a JSON reporter for ApiPort

Downloads

Location
ApiPort CLI ApiPort Download
Visual Studio Extension Open VSIX Gallery

Privacy:

We only send .NET APIs and its caller user assembly names to the service to analyze for portability and generate report. For more information, check out our privacy policy.

How to Engage, Contribute and Provide Feedback

Here are some ways to contribute:

Want to get more familiar with what's going on in the code?

Looking for something to work on? The list of up-for-grabs issues is a great place to start.

Related Projects

For an overview of all the .NET related projects, have a look at the .NET home repository.

License

This project is licensed under the MIT license.

dotnet-apiport's People

Contributors

aarnott avatar alexghiondea avatar alinapopa avatar bashenk avatar brandonh-msft avatar brunowarmling avatar chi-qin avatar chlowell avatar conniey avatar darwinjs avatar dependabot[bot] avatar dlemstra avatar drewscoggins avatar dsplaisted avatar glennblock avatar huanwu avatar jeremymeng avatar jjvertical avatar khellang avatar loopedbard3 avatar lxiamail avatar mairaw avatar martinivarsson avatar microsoft-github-policy-service[bot] avatar mjrousos avatar mmitche avatar nmbro avatar terrajobst avatar tugberkugurlu avatar twsouthwick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet-apiport's Issues

Show the contract that an API belongs to

The page that shows details for an API should show which contract it is included in. This will tell people which NuGet package they need to reference in .NET Core projects in order to use the API.

VS Extension 1.1.10808.0: Information on Type usage

When I analyze my C# Portable Client Library in VC 2015, I get error icon on targets .NET Framework 4.6.1, Mono 3.3.0.0, Xamarin.Android 4.12.1 and Xamarin.iOS 7.2.2:

System.Type

get_Name

I think some recommended changes needs to be added here.
I couldn't really find anything about this issue at first, but from #113 and https://dotnetcademy.net/Learn/4/Pages/3 I recon I need to change to TypeInfo.

Keep up the good work!

Kind Regards,
Keld ร˜lykke

Constructing arrays of primitive types lead to an argument null exception

MemberMetadataInfoTypeProvider does not provide a 'defined in assembly' for array ctors, such as 'new int[,]'. This leads to an argument null exception when the defined-in-assembly is referenced to determine whether the API is in the Framework or not.

Actual Behavior
ApiPort fails with an ArgumentNullException while finding dependencies for this code:

using System;
public class myClass
{
   static void Main()
   {
       Foo();
   }
   public static void Foo()
   {
    var i = new int[1,2];
    Console.WriteLine(i.Length);
   }
}

The exception thrown is:

ArgumentNullException: Value cannot be null.
Parameter name: assemblyName
   at System.Reflection.AssemblyName..ctor(String assemblyName)
   at Microsoft.Fx.Portability.Analysis.AnalysisEngine.GetAssemblyIdentityWithoutCultureAndVersion(String assemblyIdentity) in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability\Analysis\AnalysisEngine.cs:line 205

Expected Behavior
This simple app should be analyzed correctly, and the tool should recognize that new int[,] is a Framework API.

Library does not build in Linux

kpm pack fails because powershell is not on Linux.

Due to this: project.json: Line 12

ubuntu-vm@ddconniey006:~/git/dotnet-apiport/src/Microsoft.Fx.Portability$ kpm pack
System.ComponentModel.Win32Exception: ApplicationName='powershell', CommandLine='-NoProfile -ExecutionPolicy unrestricted -file /home/ubuntu-vm/git/dotnet-apiport/src/Microsoft.Fx.Portability\Resources\CreateLocalizedStrings.ps1', CurrentDirectory='/home/ubuntu-vm/git/dotnet-apiport/src/Microsoft.Fx.Portability', Native error= Cannot find the specified file
  at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.ScriptExecutor.Execute (Microsoft.Framework.Runtime.Project project, System.String scriptName, System.Func`2 getVariable) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.BuildManager.Build () [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.Program+<>c__DisplayClass3_3.<Main>b__6 () [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

Usage of TypeInfo members is incorrectly reported as not supported when analyzing .NET Framework assemblies

A bunch of APIs on Type are not supported in .NET Core. Running ApiPort on an assembly that uses these types will recommend adding a call to GetTypeInfo(). Doing so will indeed make the code portable to .NET Core. However, running the portability analyzer on an assembly that does call GetTypeInfo() for these APIs will still report them as unsupported.

This is because for the .NET Framework, TypeInfo derives from Type and simply inherits those APIs. So in the method table you never see TypeInfo.get_Assembly, just Type.get_Assembly even if you are accessing it via a TypeInfo object.

To report portability of these APIs correctly would probably require analyzing the IL at the call sites.

The APIs on Type are some of the most common ones encountered that aren't supported on .NET Core. So this issue makes it hard to use ApiPort to track progress towards .NET Core compatibility.

Docid generation for implicit operators is incorrect

Use the following code as the input to the dependency finder:

namespace Microsoft.Fx.Portability.MetadataReader.Tests
{
    class CallOtherClass
    {
        static void Main(string[] args)
        {
            Class1<int> list = new Class2<int>();
        }
    }

    public class Class1<T> { }

    internal struct Class2<T>
    {
        public static implicit operator Class1<T>(Class2<T> other)
        {
            return new Class1<T>();
        }
    }
}

The generated docid for the implicit operator is incorrect.

Expected: M:Microsoft.Fx.Portability.MetadataReader.Tests.Class21.op_Implicit(Microsoft.Fx.Portability.MetadataReader.Tests.Class2{0})~Microsoft.Fx.Portability.MetadataReader.Tests.Class1{0}**Actual:**M:Microsoft.Fx.Portability.MetadataReader.Tests.Class21.op_Implicit(Microsoft.Fx.Portability.MetadataReader.Tests.Class2{0})`

DocId is not generated correctly for a generic method within a generic class with different generic types

The docid for the method MemberWithDifferentGeneric in the example below is not generated correctly.

Expected: M:ConsoleApplication2.GenericClass1.MemberWithDifferentGeneric1(0)`

Observed: M:ConsoleApplication2.GenericClass1.MemberWithDifferentGeneric(``0)`

namespace Microsoft.Fx.Portability.MetadataReader.Tests.Tests
{
    class CallOtherClass
    {
        static void Main(string[] args)
        {
            GenericClass<int>.MemberWithDifferentGeneric("hello");
        }
    }

    public class GenericClass<TResult>
    {
        internal static TResult MemberWithDifferentGeneric<TAntecedentResult>(TAntecedentResult result)
        {
            return default(TResult);
        }
    }
}

Add documentation for all public APIs

I enabled xml documentation generation, and there are a number of APIs that do not have documentation. We should add that, and then remove the warning suppression in the projects.

Events are not included in dependency report

As per the spec:

    /// <summary> 
    /// Enter description for event. 
    /// ID string generated is "E:N.X.d".
    /// </summary> 
    public event D d;

Currently, no events are found in the dependency finder

Multidimensional arrays with a primitive type cannot find assembly defined in

Use the following as input:

namespace Microsoft.Fx.Portability.MetadataReader.Tests.Tests
{
    namespace Microsoft.Fx.Portability.MetadataReader.Tests
    {
        class ArrayCreation
        {
            static void Main(string[] args)
            {
                var b = new int[3, 2];
            }
        }
    }
}

Expected type info:

"Key": {
    "DefinedInAssemblyIdentity": "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
    "MemberDocId": "M:System.Int32[0:,0:].#ctor(System.Int32,System.Int32)",
    "TypeDocId": "T:System.Int32",
    "RecommendedChanges": null,
    "SourceCompatibleChange": null,
    "TargetStatus": null
  }

What we see right now:

"Key": {
    "DefinedInAssemblyIdentity": null,
    "MemberDocId": "M:System.Int32[0:,0:].#ctor(System.Int32,System.Int32)",
    "TypeDocId": "T:System.Int32",
    "RecommendedChanges": null,
    "SourceCompatibleChange": null,
    "TargetStatus": null
}

Add API search support to dotnetstatus site

Right now there is a "search" box with autocomplete. If you type (or use autocomplete to get) the full name of the API, then you can navigate to the page for that API. But there's no search results page and no way to search using a partial name.

We should:

  • Add a search results page
  • Support searching for partial names
  • Show types in the search results in addition to members

ApiPort's metadata reader fails on some AppCompat-lab assets

System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at System.Reflection.Metadata.Decoding.SignatureDecoder.DecodeType[TType](BlobReader& blobReader, SignatureTypeCode typeCode, ISignatureTypeProvider1 provider) in d:\Builds\1161\dotnetcore\corefx-dev-metadata-realsigned\src\src\System.Reflection.Metadata\src\System\Reflection\Metadata\Decoding\SignatureDecoder.cs:line 143 at System.Reflection.Metadata.Decoding.SignatureDecoder.DecodeModifiedType[TType](BlobReader& blobReader, ISignatureTypeProvider1 provider, Boolean isRequired) in d:\Builds\1161\dotnetcore\corefx-dev-metadata-realsigned\src\src\System.Reflection.Metadata\src\System\Reflection\Metadata\Decoding\SignatureDecoder.cs:line 404
at System.Reflection.Metadata.Decoding.SignatureDecoder.DecodeType[TType](BlobReader& blobReader, SignatureTypeCode typeCode, ISignatureTypeProvider1 provider) in d:\Builds\1161\dotnetcore\corefx-dev-metadata-realsigned\src\src\System.Reflection.Metadata\src\System\Reflection\Metadata\Decoding\SignatureDecoder.cs:line 126 at System.Reflection.Metadata.Decoding.SignatureDecoder.DecodeMethodSignature[TType](BlobReader& blobReader, ISignatureTypeProvider1 provider) in d:\Builds\1161\dotnetcore\corefx-dev-metadata-realsigned\src\src\System.Reflection.Metadata\src\System\Reflection\Metadata\Decoding\SignatureDecoder.cs:line 222
at System.Reflection.Metadata.Decoding.SignatureDecoder.DecodeMethodSignature[TType](BlobHandle handle, ISignatureTypeProvider1 provider) in d:\Builds\1161\dotnetcore\corefx-dev-metadata-realsigned\src\src\System.Reflection.Metadata\src\System\Reflection\Metadata\Decoding\SignatureDecoder.cs:line 176 at Microsoft.Fx.Portability.Analyzer.MemberMetadataInfoTypeProvider.GetMemberRefInfo(MemberReference memberReference) in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability.MetadataReader\MemberMetadataInfoTypeProvider.cs:line 42 at Microsoft.Fx.Portability.Analyzer.DependencyFinderEngineHelper.GetMemberReferenceMemberDependency(MemberReference memberReference) in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability.MetadataReader\DependencyFinderEngineHelper.cs:line 101 at Microsoft.Fx.Portability.Analyzer.DependencyFinderEngineHelper.ComputeData() in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability.MetadataReader\DependencyFinderEngineHelper.cs:line 60 at Microsoft.Fx.Portability.Analyzer.ReflectionMetadataDependencyInfo.GetDependencies(String assemblyLocation) in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability.MetadataReader\ReflectionMetadataDependencyInfo.cs:line 100 at Microsoft.Fx.Portability.Analyzer.ReflectionMetadataDependencyInfo.<FindDependencies>b__15_0(String filename) in C:\git\MJRousos\dotnet-apiport\src\Microsoft.Fx.Portability.MetadataReader\ReflectionMetadataDependencyInfo.cs:line 63 at System.Linq.Parallel.ForAllOperator1.ForAllEnumerator1.MoveNext(TInput& currentElement, Int32& currentKey) at System.Linq.Parallel.ForAllSpoolingTask2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()

Nested class with >9 type parameters fails to create correct docid

Use the following code as the input to the dependency finder:

namespace Microsoft.Fx.Portability.MetadataReader.Tests
{
    class CallOtherClass
    {
        static void Main(string[] args)
        {
            var @class = new Class<int, int, int, int, int, int, int, int, int, int>();
            var innerClass = new Class<int, int, int, int, int, int, int, int, int, int>.InnerClass(@class, 1);
        }
    }

    public class Class<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
    {
        public class InnerClass
        {
            public InnerClass(Class<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> @class, T3 param)
            {

            }
        }
    }
}

The generated docid for the InnerClass constructor is incorrect.

Expected: M:Microsoft.Fx.Portability.MetadataReader.Tests.Class10.InnerClass.#ctor(Microsoft.Fx.Portability.MetadataReader.Tests.Class{0,1,2,3,4,5,6,7,8,9},2)
Actual: M:Microsoft.Fx.Portability.MetadataReader.Tests.Class10.InnerClass.#ctor(Microsoft.Fx.Portability.MetadataReader.Tests.Class{0}0,2)`

ApiPort fails with the message - There was an unknown error while reaching the service

Trying to run the Apiport.exe -listTargets. It runs and then fails with the message;

Microsoft (R) API Portability Analyzer v1.0.251.0
Copyright (C) Microsoft Corporation. All rights reserved.

To learn more about how this tool works, including the data we are collecting, go here - http://go.microsoft.com/fwlink/?LinkId=397652

Retrieving targets [Failed]

There was an unknown error attempting to reach the service. Please try again.

Some reason the service is not reachable and it fails. I downloaded the Apiport from http://www.microsoft.com/en-us/download/details.aspx?id=42678

Non-generic types with generic arguments are not decoded correctly by MDReader

It is (bizarrely) possible to define non-generic types in IL that accept generic arguments. DocIDs for such types are produced incorrectly by our MemberMetadataInfoTypeProvider (the generic arguments are omitted).

Test Code To Analyze

.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )  
  .ver 4:0:0:0
}
.assembly NonGenericTypesWithGenericParameters
{}

.module NonGenericTypesWithGenericParameters.dll

.corflags 0x00000001    //  ILONLY

.class public auto ansi beforefieldinit OuterClass<a,b>
{
  .class auto ansi nested public beforefieldinit InnerClass<a,b,c,d>
  {
    .method public hidebysig static void 
            InnerMethod(class OuterClass/InnerClass<!c,!c> param1) cil managed
    {
      // Code size       9 (0x9)
      .maxstack  8
      IL_0000:  nop
      IL_0001:  ldarg.0
      IL_0002:  call       void class OuterClass/InnerClass<!a,!b,!c,!d>::InnerMethod(class OuterClass/InnerClass<!2,!2>)
      IL_0007:  nop
      IL_0008:  ret
    } // end of method InnerClass::InnerMethod
  } // end of class InnerClass

  .method public hidebysig static void  OuterMethod(!a param1,
                                                    class OuterClass/InnerClass<!b,!a,object,!a> param2) cil managed
  {
    // Code size       10 (0xa)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ldarg.0
    IL_0002:  ldarg.1
    IL_0003:  call       void class OuterClass<!a,!b>::OuterMethod(!0,
                                                                     class OuterClass/InnerClass<!1,!0,object,!0>)
    IL_0008:  nop
    IL_0009:  ret
  } // end of method OuterClass::OuterMethod
} // end of class OuterClass

Expected Dependencies
[0]: "M:OuterClass.InnerClass.InnerMethod(OuterClass.InnerClass{2,2})"
[1]: "M:OuterClass.OuterMethod(0,OuterClass.InnerClass{1,0,System.Object,0})"
[2]: "T:OuterClass"
[3]: "T:OuterClass.InnerClass"
[4]: "T:System.Object"

Actual Dependencies
[0]: "M:OuterClass.InnerClass.InnerMethod(OuterClass.InnerClass)"
[1]: "M:OuterClass.OuterMethod(`0,OuterClass.InnerClass)"
[2]: "T:OuterClass"
[3]: "T:OuterClass.InnerClass"
[4]: "T:System.Object"

Some op_Implicit methods shouldn't have `~[ReturnType]` appended to it

Use the following code as input:

namespace Microsoft.Fx.Portability.MetadataReader.Tests.Tests
{
    namespace Microsoft.Fx.Portability.MetadataReader.Tests
    {
        class opImplicitTest
        {
            static void Main(string[] args)
            {
                byte b = 5;
                decimal d = b; 
            }
        }
    }
}

The implicit conversion from byte to decimal uses the op_Implicit method on System.Decimal. The docid for it is not generated correctly:

Expected: M:System.Decimal.op_Implicit(System.Byte)
Actual: M:System.Decimal.op_Implicit(System.Byte)~System.Decimal

ApiPort crashes on Mono (EntryPointNotFoundException: CreateZStream)

mono ~/Downloads/ApiPort.exe src/Logary/bin/Debug/Logary.dll
Microsoft (R) API Portability Analyzer version 1.0 (alpha)
Copyright (C) Microsoft Corporation. All rights reserved.

To learn more about how this tool works, including the data we are collecting, go here - http://go.microsoft.com/fwlink/?LinkId=397652

Identifying assemblies to scan. Done in 0.01s.
Detecting assembly references. Processed 1/1 files.Done in 0.50s.
Sending data to service. |Could not load signature of System.Net.Http.HttpContentExtensions:ReadAsAsync due to: Could not load file or assembly or one of its dependencies.
Sending data to service. Failed after 0.40s
[ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> System.BadImageFormatException: Could not resolve signature of method System.Net.Http.HttpContentExtensions:ReadAsAsync
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[<CallInternalAsync>d__c`1] (Microsoft.Fx.PortabilityAnalyzer.Shared.Service.<CallInternalAsync>d__c`1& stateMachine) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].Start[<CallInternalAsync>d__c`1] (Microsoft.Fx.PortabilityAnalyzer.Shared.Service.<CallInternalAsync>d__c`1& stateMachine) [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.HttpClientExtensions.CallInternalAsync[AnalyzeResponse] (System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, Boolean compressed) [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.HttpClientExtensions+<CallAsync>d__4`2[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeRequest,Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse].MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].GetResult () [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ApiPortService+<SendAnalysisAsync>d__5.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.ApiPortClient+<GetResultFromService>d__7.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[ApiPort.Reporting.ObjectModel.ReportingResult].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.ApiPortClient+<AnalyzeAssemblies>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[ApiPort.Reporting.ObjectModel.ReportingResult].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.Program+<AnalyzeAssemblies>d__4.MoveNext () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.Wait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.Wait () [0x00000] in <filename unknown>:0
  at ApiPort.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
---> (Inner Exception #0) System.BadImageFormatException: Could not resolve signature of method System.Net.Http.HttpContentExtensions:ReadAsAsync
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[<CallInternalAsync>d__c`1] (Microsoft.Fx.PortabilityAnalyzer.Shared.Service.<CallInternalAsync>d__c`1& stateMachine) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].Start[<CallInternalAsync>d__c`1] (Microsoft.Fx.PortabilityAnalyzer.Shared.Service.<CallInternalAsync>d__c`1& stateMachine) [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.HttpClientExtensions.CallInternalAsync[AnalyzeResponse] (System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, Boolean compressed) [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.HttpClientExtensions+<CallAsync>d__4`2[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeRequest,Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse].MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].GetResult () [0x00000] in <filename unknown>:0
  at Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ApiPortService+<SendAnalysisAsync>d__5.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Fx.PortabilityAnalyzer.Shared.Service.ServiceResponse`1[Microsoft.Fx.PortabilityAnalyzer.DataContracts.AnalyzeResponse]].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.ApiPortClient+<GetResultFromService>d__7.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[ApiPort.Reporting.ObjectModel.ReportingResult].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.ApiPortClient+<AnalyzeAssemblies>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[ApiPort.Reporting.ObjectModel.ReportingResult].GetResult () [0x00000] in <filename unknown>:0
  at ApiPort.Program+<AnalyzeAssemblies>d__4.MoveNext () [0x00000] in <filename unknown>:0 <---

Use recommended changes from containing APIs

When looking for recommended changes at the member level, API port should fall back to the recommended changes at the chain of containing types, up to, and including the namespaces.

This makes it a lot easier for us to have a complete list of recommendations without having to add them to each and every member.

So when looking for recommendations of System.Runtime.Awesome.Type.Subtype.Member, it should probe in the following order:

  1. M:System.Runtime.Awesome.Type.Subtype.Member
  2. T:System.Runtime.Awesome.Type.Subtype
  3. T:System.Runtime.Awesome.Type
  4. N:System.Runtime.Awesome
  5. N:System.Runtime
  6. N:System

Command-line parameters are case-sensitive

This command: "apiport analyze --showBreakingChanges --resultFormat=HTML -f=." produces an output file that has no extension and, upon renaming, turns out to actually be an xlsx file. Investigating, it appears that the issue is that '--resultFormat' isn't recognized because it doesn't match the expected case of resultformat.

Add an input to tell the analyzer what runtime is being used

When calculating braking changes, it would be helpful to let the analyzer know what the desired target framework would be. Right now, all known breaking changes would be returned, when this could be trimmed if we know what the desired target is.

Portability HTML report showing different results when analyzing library

Running a library through ApiPort by itself or used in a dependency of a project results in different portability results being shown.

Repro:

  • Build Microsoft.Fx.Portability
  • Run ApiPort:
    • .\src\ApiPort\bin\Debug\ApiPort.exe analyze -f="src\Microsoft.Fx.Portability\bin\Debug\net45" -o="portability.html" -r=HTML
  • Build Microsoft.Fx.Portability.MetadataReader
    • .\src\ApiPort\bin\Debug\ApiPort.exe analyze -f="src\Microsoft.Fx.Portability.MetadataReader\bin\Debug" -r=HTML -o="MetadataReader.html"
  • Compare results

You'll notice that MetadataReader.html has more calls than Portability.html did.

Also, I notice that the checkmark and error icons are duplicated when we write out the target class.
image
I'm fairly confident that the List<T> class is supported in all platforms though.. so it seems to be duplicating the message for AsReadOnly

Assembly is skipped in report depending on order of input

Scenario: c.dll has a reference on b.dll

ApiPort.exe -f a.dll -f b.dll -f c.dll

b.dll would not show up in report. It would show up with the following order:

ApiPort.exe -f a.dll -f b.dll -f c.dll -f b.dll

Notice the duplication of b.dll (or that b.dll is listed after c.dll)

Iterator block for IEnumerable<T1<T2,T3>> generates incorrect docid

Use the following as the input assembly:

using System;
using System.Collections.Generic;

namespace Microsoft.Fx.Portability.MetadataReader.Tests
{
    class CallOtherClass
    {
        static void Main(string[] args)
        {
            OtherClass.GetValues<int>();
        }
    }

    public class OtherClass
    {
        internal static IEnumerable<Tuple<T, int>> GetValues<T>()
        {
            yield break;
        }
    }
}

The docid generated for GetValues is incorrect - there is a @ where there should be a #.

Expected: M:Microsoft.Fx.Portability.MetadataReader.Tests.OtherClass.<GetValues>d__01.System#Collections#Generic#IEnumerable{System#Tuple{T@System#Int32}}#GetEnumerator**Actual:**M:Microsoft.Fx.Portability.MetadataReader.Tests.OtherClass.d__01.System#Collections#Generic#IEnumerable{System#Tuple{T,System#Int32}}#GetEnumerator

The generics may be a red herring, but that's the only way I can get it to compile in a way that it is detected by the dependency finder. There are probably compiler optimizations in other cases.

Constant fields are not found by dependency finder

As per the spec:

    /// <summary> 
    /// Enter description for constant PI. 
    /// ID string generated is "F:N.X.PI".
    /// </summary> 
    public const double PI = 3.14;

Normal fields are found just fine, but constant fields are not

MD Reader type provider does not decode __arglist usage correctly

The metadata reader is returning the specific types passed as varargs instead of the general varargs __arglist keyword.

Code:

public class TestClass
{
    public static void ArglistMethod(int i, __arglist)
    {
    }

    public static void Main(string[] args)
    {
        ArglistMethod(5, __arglist(1, 2, 3));
    }
}

_Expected DocID for method reference_
M:TestClass.ArglistMethod(System.Int32,__arglist)

_Actual DocID for method reference_
M:TestClass.ArglistMethod(System.Int32,System.Int32,System.Int32,System.Int32)

Switch ApiPort to use DNX

Currently ApiPort targets .NET Framework 4.6, but we could switch it to use DNX on .NET Core so it doesn't have the 4.6 requirement.

Details/suggestions needed for some breaking changes

Some breaking change files are missing details/suggestions:

  • Microsoft/dotnet-apiport/docs/BreakingChanges/012 ComposablePartCatalog and its derived classes.md
  • Microsoft/dotnet-apiport/docs/BreakingChanges/015 Delegates pointing to extension methods lead to InvalidProgramException.md
  • Microsoft/dotnet-apiport/docs/BreakingChanges/016 Calling base method from an anonymous method causes exception.md

API details page should make it easy to add / edit recommended changes

If I look up an API that's not available on .NET Core and it doesn't have any recommended changes, I should be able to easily add information about what to replace it with. Ideally the recommended changes would be stored in a GitHub repo, and the API details page could include a link that would start a pull request to add recommended changes for the API.

Multidimensionial array not formed correctly in argument list

Per the spec:

    /// <summary> 
    /// Enter description for method gg. 
    /// ID string generated is "M:N.X.gg(System.Int16[],System.Int32[0:,0:])". 
    /// </summary> 
    /// <param name="array1">Describe parameter.</param>
    /// <param name="array">Describe parameter.</param>
    /// <returns>Describe return value.</returns> 
    public int gg(short[] array1, int[,] array) { return 0; }

But the docid formed is M:N.X1.gg(System.Int16[],System.Int32)`

ApiPort fails to analyze very large IL files

Very large assemblies (larger than ~25MB) cannot be analyzed because of a metadata reader limitation (dotnet/corefx#1588).

I'm investigating a fix, but it involves non-trivial changes to the metadata reader.

MD Reader type provider does not decode optional modifiers correctly

IL:

.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
  .ver 4:0:0:0
}
.assembly ModOpt
{}

.module ModOpt.dll

.corflags 0x00000001    //  ILONLY

.class public auto ansi beforefieldinit TestClass
{
  .method public hidebysig instance void
          Foo(int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) x) cil managed
  {
    ldarg.0
    call void TestClass::Foo(int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst))
  } // end of method TestClass::Foo 
} // end of class TestClass

Expected dependency: M:TestClass.Foo(System.Int32 optmod System.Runtime.CompilerServices.IsConst)

Actual dependency: M:TestClass.Foo(~System.Int32modopt(System.Runtime.CompilerServices.IsConst))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.