Declined
Last Updated: 05 Dec 2019 15:32 by ADMIN
Koushik
Created on: 20 Nov 2019 12:44
Type: Bug Report
1
[Duplicate] Visual Studio debugger arrowhead pointer is messed when profiler is enabled with .Net Core 2.1

Visual Studio debugger arrowhead pointer is messed when profiler is enabled with .Net Core 2.1, in VS2107/2019

Steps

  • Use elevated features like static mocking using JustMock
  • Enable profiler from VS JustMock extension
  • Run the test in debug mode

Code Snippet

Mock.SetupStatic(typeof(ElasticOperationsHelper), Behavior.Strict, StaticConstructor.Mocked);

Mock.Arrange(() => elasticRepository.IndexDocumentInElastic<IndexDocText>(Arg.IsAny<IndexDocText>(), Arg.IsAny<string>(), null)).Returns(response);

 

While debugging it's found the arrowhead pointer of VS debugger is messed up and pointing to wrong line numbers. It's quite difficult to develop unit tests at this situation. Is there any resolution of this problem.

I found an article in the support page has been declined due to same problem. Is this totally dependent on "CLR" fix and .Net profiler. If so could you please provide me the Bug details of Microsoft for the same?

I would also like to know why it's necessary to have profiler enabled for scenarios like "Static Mocking", "Non virtual method mocking", "Private Mocking" etc. 

Is this only happening for .Net core? 

Hyland Software is evaluating this product as their Mocking framework for unit testing of all .net core projects.

If there is no solution, how can any prospective customer consider this as a good fit for their usage? If there is any workaround possible at this moment?

3 comments
ADMIN
Mihail
Posted on: 05 Dec 2019 15:32

Hi everybody,

We have now tested the official release of .NET Core 3.1 and we can confirm that the fix is included. Our recommendation is all projects experiencing the issues with the debugger arrowhead to be migrated to .NET Core 3.1.

I will change the status of this item as declined as it is a duplicate of already existing one. Here is again the link.

Regards,
Mihail
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
ADMIN
Mihail
Posted on: 27 Nov 2019 12:02

Hi,

@Koushik, as you pointed out we already have this issue logged in our feedback portal. We are absolutely aware of the impact it has on JustMock and on the ability of the developers to write and debug unit tests.

This is why six months ago when we found out about the problem we contacted Microsoft and they confirmed that the problem is in the CLR. Here is a link to the bug report item in the CLR if you are interested. Please have in mind that most of the communication was in a private channel to protect our intellectual property. 

Since then we have tried to implement numerous fixes and workarounds on our side to overcome the problem. Some of them were suggested from MS. Sadly with no success. By no success, I mean that everything works as expected and by our standards for all supported features.

Happily, the problem was fixed by MS. However, the MS process of including an already confirmed fix in an official release is kinda cumbersome.
The good news is that we have confirmed that the latest .NET Core 3.1 preview includes the fix. If you are at the development phase of your application I would recommend you as a workaround at this point to use this version. Later when the official .NET Core 3.1 version is released (December 2019) you could switch to it.

Regarding older versions of .NET Core, we have tested a custom builds for 2.1(LTS) and 3.0 and we have confirmed that the issue is fixed there. However, we do not have any specificity when the fix will be included in the mentioned versions.

Regarding your question of why a profiler is needed for elevated mocking (static, private, non-virtual, etc), I will try to briefly explain it. 

To create its mock object and all arrangements related to this mock object a mocking framework has to inherit a specific class and override the required method or property.

I will first start with how the free version, JustMock Lite works. To create a mock object and all arrangements related to this mock object JustMock Lite has to inherit a specific public class or interface and override the required method or property. And what can be inherited in C# and VB roughly are public interfaces, abstract classes, and virtual methods or properties. In essence, the implemented logic for each mocked method is simply adding a conditional check and it goes like this: If there are any arrangements for this method process them, otherwise call the original code.

The approach with the inheritance is limited to what can be mocked as I already explained. And elevated mocking (static, private, non-virtual, etc) can't be performed due to this limitation. This limitation is solved by JustMock which is a paid version.

JustMock is based on JustMock Lite and uses the same approach for public interfaces, abstract classes, and virtual methods or properties. To support elevated mocking JustMock has to add the conditional check that was already mentioned to static, private, non-virtual, sealed or other third-party API. This additional code has to be added before the JIT compilation is done by the CLR and this can only be achieved through a profiler.

@Sourav I completely agree with you. A flowless debugging should be available for all development products. You should also have in mind that the position of the debugger arrowhead pointer is calculated and provided by the .NET CLR to the Visual Studio debugger. And if there is a bug in the calculations what we can do is cooperate with MS to fix it as soon as possible. This is exactly what we have done.

I hope this information answers your questions.

Regards,
Mihail
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Sourav
Posted on: 20 Nov 2019 12:51

The arrowhead pointer issue is causing a lot of debugging headaches and should be a very basic feature in a mocking framework. As there is organization wide mandate in many places for strict adherence to .NET core, this particular bug is an irritating one and significantly increases development time.

Any prompt resolution to this bug or any workaround is greatly appreciated