Why does VS2015 Code Analysis choke on calls to Insights Assembly from PCL?

I'm moving from Windows 8 and VS2013 to Windows 10 and VS2015. But I ran into a problem where code analysis breaks as soon as it hits a call to Insights from the core PCL project. Doing the same from the Windows Phone project works fine.

There's two different types of errors:

  • A call to Insights.Identify call triggers the error:
    Could not resolve reference to mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes.

  • A call to Insights.Report or Insights.Track will generate the above error and also numerous of the same warnings for a lot of rules saying:
    CA0001 : An error was encountered while parsing IL for method: '[Where you make the call]', instruction at offset '0x..' with opcode 'Call'.

It was very easy to reproduce by simply creating a Xamarin Forms project, adding insights and enabling Code Analysis. See the attached solution and the xml file with the Code Analysis log. Since this is so easy to reproduce I get the feeling I'm simply missing something here?

Answers

  • PatriceHuotPatriceHuot USMember, University

    Any progress on this issue?
    I have the same problem. For now the only work around I found is to do the dev in VS2015, but check the code analysis in VS2013.

  • MeeraMenonMeeraMenon INMember

    Have you got any solution? I am facing same issue with VS 2015 and code analysis.

  • Ferry.de.BoerFerry.de.Boer NLUniversity ✭✭

    Nope, I'm still having occasional communication with support on this. I hinted them to other libraries which seemed to have a similar problem. There the cause apparently was in de the fact that these libraries were built against .net 4.0 while the PCL targets 4.5 which splitted up certain libs. It's silent again for the past two weeks.

  • Ferry.de.BoerFerry.de.Boer NLUniversity ✭✭

    Just to collect some more information here. Which PCL profile are you guys building against?

  • AndyJoinerAndyJoiner USMember
    edited July 2016

    I'm using Profile259

    Most of my errors look like this:

    CA0001 : Rule=Microsoft.Globalization#CA1306, Target=MyClass...PclFileTransferHTTP.#CreateHttpClient(System.Net.Http.HttpClientHandler) : An error was encountered while parsing IL for method: 'MyClass...PclFileTransferHTTP.CreateHttpClient(System.Net.Http.HttpClientHandler)', instruction at offset '0x33' with opcode 'Callvirt'.

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    I get this too. Sometimes it stops me dead in my tracks. Other times I just have to hit compile a few more times.

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    I have narrowed the problem down to one file that is using XAMLC [XamlCompilation(XamlCompilationOptions.Compile)]

    The problem only comes up with Code Analysis turned on. If I remove this attribute from the class, the code analysis doesn't choke. However, when I turn it off, I get an error in the app. Essentially, something in the XAML of this class only works with XAMLC turned on, but code analysis only works when it is turned off. This needs to be fixed.

Sign In or Register to comment.