roslyn: Running Code Metrics on CPS project targeting .NET Core/.NET Standard displays an error

Version Used: 15.8 Preview 3

Steps to Reproduce:

  1. File -> Console App (.NET Core) or Class Library (.NET Standard)
  2. Analyze -> Calculate Code Metrics -> For [ConsoleApp]

Expected Behavior: Succeeded

Actual Behavior:

Message: An error occurred while calculating code metrics for target file 'c:\users\davkean\Source\Repos\ConsoleApp341\ConsoleApp341\bin\Debug\netcoreapp2.0\ConsoleApp341.dll' in project ConsoleApp341. Could not identify platform for 'c:\users\davkean\Source\Repos\ConsoleApp341\ConsoleApp341\bin\Debug\netcoreapp2.0\ConsoleApp341.dll'.

Note: If you target .NET Framework from the project than it succeeds.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 17 (14 by maintainers)

Most upvoted comments

I’d very much like to see Code Metrics support added for Core/Standard projects. Please consider it as a priority to include in an upcoming (soon) release, since currently behavior feels like VS is going backward, losing functionality it’s had for many years/versions. Thanks!

This error is still present for .NET Core Projects. (.net core version 2.1) (VS Version 15.8.1)

  1. Create new .NET Core Console Application.
  2. Calculate Code Metrics.

To clarify: With Dev16 P1, Code Metrics should work for all C# and VB projects.

Given the number of customer requests, we have also ported Code metrics related FxCop rules to analyzers with https://github.com/dotnet/roslyn-analyzers/pull/1740. We also plan to provide a command line executable, such as Metrics.exe in pre-Dev15 versions, https://github.com/dotnet/roslyn-analyzers/issues/1741 tracks that work.

@bearslumber It is not part of VS2017 (i.e. version 15.x.x or Dev15), but should be part of VS2019 (i.e., version 16.x.x or Dev16). See https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview.

On second thought, I feel we should do nothing here in 15.8 and instead figure out the story for Code Metrics for 16.0: deprecate it or fully support it for all TFMs, especially as we are very sure that we want to deprecate binary FxCop and the FxCop analysis engine that current Code Metrics implementation is based upon in 16.0. Current experience for CPS projects, though not ideal, neither blocks any supported feature nor leads to a crash/hang/performance issue to warrant a short term fix. @jinujoseph to make a call.

Make note, we recently changed Project.Kind to return the legacy project system which unblocked this path and Code Metrics now shows up.