locked
Method names in Code Coverage results generated by MSTest RRS feed

  • Question

  • Hi guys,

    I've set MSTest to collect code coverage data while running unit test.

    But how come the method names are all mis-formatted? Like b__1(int32), .cctor() and so on.

    It seems like intermediate languages (IL), but how could I matching it with the real method name?

    Is there a way to get the real name rather than IL names, or programmatically convert it back into real name?

    Thanks

    Wednesday, June 4, 2014 7:16 PM

Answers

  • Hi,

    Based on your sample, we have been reproduced it in VS2010, and I found the same issue with you. After our discussions, we find the reason that it may be internal design by in VS. As far as I know, when we collected the code coverage data using VS2010 or mstest.exe, the code coverage data results are collected through the IL language. It is the internal design in VS, we might not change it.

    In order to ensure the cause of the issue, we try to create a simple solution in VS2010. However, I also found that when I view the code coverage data result in the Code Coverage Result Viewer, the name displayed also is .ctor() rather than the constructor “Class1()” real name. The following show that our results screenshot:

    In addition, I also reproduced your project in VS2013. I found the constructor “CommandParser()” name in class and the code coverage viewer name are same. If you need to view the real name, you can install the vs2013. However, you need to notice that if you collect the code coverage data using mstest.exe, when you view the results in VS2013, it will occur the constructor name is .ctor() rather than real name.

    This is what I mentioned before, when we collect code coverage data by the internal default IL language to show the results.

    Thanks for your understanding.

    Best regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, June 16, 2014 2:01 AM
    • Marked as answer by Amanda Zhu Thursday, June 19, 2014 1:33 AM
    Wednesday, June 11, 2014 10:12 AM

All replies

  • Hi,

    When you view the code coverage data result, I am not sure how to open the code coverage data result file.

    As far as I know, we usually collected code coverage data using mstest.exe, the code coverage data result saved in the test result folder. If you successfully run the code coverage data, you will find the data.coverage in test result folder, than open it by VS IDE. From the code coverage results window view the test method name whether it may be occur the same error.

    In addition, you can also rebuilt and run the unit test project, then to collect the code coverage data in VS IDE. From the code coverage results window, view whether the same error occurs in VS IDE. If yes, please give me more information about the issue. 

    If I understood it wrong, please provided us more information about the issue. We will focus on them to help you.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 5, 2014 10:05 AM
  • Thanks for your reply.

    For some reason, I need to access the data.coverage programatically.

    So I refer this page: http://msdn.microsoft.com/en-us/library/dd347161(v=vs.90).aspx

    	// Create a coverage info object from the file
            CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile("myfile.coverage");
     
            // Ask for the DataSet
            // The parameter must be null
            CoverageDS data = ci.BuildDataSet(null);
     
            // Write to XML
            data.Lines.WriteXml("mylines.xml");

    As that said, the XML file is the way I'm using to access my coverage result.

    But I do think the same thing happen in VS Code Coverage Result Viewer:

    Look at the method name in the following picture, some of them is not human readable, and definitely not the real method name in source code.

    Friday, June 6, 2014 1:26 PM
  • Friday, June 6, 2014 2:00 PM
  • Hi,

    From your message:

    As that said, the XML file is the way I'm using to access my coverage result.

    But I do think the same thing happen in VS Code Coverage Result Viewer:

    Do you mean the XML file and the Code Coverage Result Viewer occur in the same error?

    If yes, because we are not reproduced the project, it is hard for use to repro this issue on our side, could you please provide us a collect code coverage data sample which can be set to run on our side? Please attach a sample and your test project, upload them to One Drive: https://onedrive.live.com/ and then post the download link here.

    In addition, please tell us which version of Visual Studio you use.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Amanda Zhu Wednesday, June 11, 2014 9:52 AM edit
    Monday, June 9, 2014 8:28 AM
  • Hi,

    Based on your sample, we have been reproduced it in VS2010, and I found the same issue with you. After our discussions, we find the reason that it may be internal design by in VS. As far as I know, when we collected the code coverage data using VS2010 or mstest.exe, the code coverage data results are collected through the IL language. It is the internal design in VS, we might not change it.

    In order to ensure the cause of the issue, we try to create a simple solution in VS2010. However, I also found that when I view the code coverage data result in the Code Coverage Result Viewer, the name displayed also is .ctor() rather than the constructor “Class1()” real name. The following show that our results screenshot:

    In addition, I also reproduced your project in VS2013. I found the constructor “CommandParser()” name in class and the code coverage viewer name are same. If you need to view the real name, you can install the vs2013. However, you need to notice that if you collect the code coverage data using mstest.exe, when you view the results in VS2013, it will occur the constructor name is .ctor() rather than real name.

    This is what I mentioned before, when we collect code coverage data by the internal default IL language to show the results.

    Thanks for your understanding.

    Best regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, June 16, 2014 2:01 AM
    • Marked as answer by Amanda Zhu Thursday, June 19, 2014 1:33 AM
    Wednesday, June 11, 2014 10:12 AM
  • Thanks, first of all.

    So the reason behind this, is MSTest set to use IL as default, right?

    I'm not quite understand the VS2013 part:

    I think even the VS is utilized MSTest to provide us these result, right? If true, what you are saying is we get a new version of MSTest shipping along with VS2013 package? If that is also true, is that possible to get the latest MSTest as a separate component rather than upgrade to VS2013 completely?

    Wednesday, June 11, 2014 7:50 PM
  • Hi,

    Thanks for your replay.

    You said the mstest.exe is set to use IL as default, it is right.

    In addition, as you said:” is that possible to get the latest MSTest as a separate component rather than upgrade to VS2013 completely?

    It is impossible to get the latest Mstest.exe as a separate component unless you upgrade to VS2013 completely. You need to install the VS then the mstest.exe will automatically be installed. The mstest.exe is included in the VS.

    As for suggesting you install VS2013, it is because that there are some differences in the vs2010 and vs2013. I find the constructor name in class and the code coverage viewer name are same when I collect the code coverage data using VS2013 IDE. If you only need to use the mstest.exe to collect the code coverage data, you will not upgrade to the VS2013. Because we collect the code coverage data using the mstest.exe, the code coverage data results are collected through the IL language.  

    Thanks for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 12, 2014 3:09 AM
  • ok, maybe I didn't make myself clear.

    Let's say, I upgrade to VS2013, and then I use MSTest (from VS2013) to collect coverage data, I'll still get the IL names?

    The only way to have the real name is collecting data inside VS2013 IDE, is that correct?

    Thanks

    Thursday, June 12, 2014 3:09 PM
  • Hi,

    First of all, thanks for your reply.

    You said” let's say, I upgrade to VS2013, and then I use MSTest (from VS2013) to collect coverage data, I'll still get the IL names?

    You are right, if we collect the code coverage data using Mstest.exe, it will still get the IL names. It is the default design.

    In addition, as you said “The only way to have the real name is collecting data inside VS2013 IDE, is that correct?”

    I think that you may not understand the meaning what I say about upgrading to VS2013. I need to explain about suggesting you to upgrade to VS2013. Because I try to collect the code coverage data in VS2013 IDE, I find the following screenshot:

    From the collection results, I find that it changes only the constructor name in VS2013 IDE. Other some names still get by the IL language. So I only want to tell you that I find the collected  constructor name in code coverage result and real name are same in the VS2013 IDE. However, if you hope the all real names are displayed using VS2013 IDE, it is impossible.

    In short, no matter you use the Mstest.exe or the VS IDE to collect the code coverage data, it is compiled by the internal default design IL language. It couldn’t be changed by us.

    Thanks for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 13, 2014 3:03 AM
  • Ok, that's clear enough. I think I'm gonna need to figure out my own way to mapping it then.

    If there any patterns that MS used to generate these IL names? It would be great if you could provide some materials about this "IL generation formula", if there is such thing existed.

    Thanks a lot for your patient.

    Friday, June 13, 2014 3:11 PM
  • Hi,

    This magazine can help you:

    http://msdn.microsoft.com/en-us/magazine/ee412257.aspx

    You can reference 'Round Tripping with IL' section.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 16, 2014 2:00 AM