How to find all .NET Core/.NET 6-incompatible members in the solution, with the actual usage info?

Viewed 72

I have a big project on .NET Framework 4.8, and I would like to find all usages of .NET Core/.NET 6-incompatible members in the code.

There are some tools from Microsoft but, unfortunately, they don't provide the information about the actual place in the source code where an incompatible member is used.

For example, there is .NET Portability Analyzer but it works with assemblies by using System.Reflection.Metadata.MetadataReader inside to retrieve all incompatible MemberInfo used in the assembly. So it outputs a list of incompatible types and members used in the project but has no information about where they are used, or how many usages there are.

I also tried .NET Upgrade Assistant hoping that its analyze command would help but it doesn't support a lot of .NET Framework types and scenarios. For example, it missed a new AppDomainSetup() call or calls to any ASP.NET Web Forms classes like System.Web.UI.Control that .NET Portability Analyzer reported as non-compatible. It seems that it knows only about ASP.NET MVC/Windows Forms/WPF-specific things.

I am trying to retrieve this detailed information to be able to track the progress of our migration. So I would like to run this kind of analysis automatically in the CI/CD pipeline, retrieving the list of incompatible usages, and comparing it with the previous report to get a clear picture of whether we have new incompatible calls added by a new pull request.

Any suggestions on how I can get this kind of information would be much appreciated.

The only thing that comes to my mind is to get the report from .NET Portability Analyzer, iterate through all incompatible types&members, and use Roslyn to find all usages in the source code, but this solution involves a lot of work.

0 Answers
Related