Svetlozar

When you link profilers you must set COR_PROFILER to be the other profiler guid, not JustMock. The CLR can attach only one profiler effectively set by COR_PROFILER. We have implemented the linking by replacing the other profiler dll path with JustMock dll path. When the CLR requests OpenCover it will load JustMock because the dll path in the registry points to JustMock. JustMock calls back the "original" profiler when done. In your case you need to have the OpenCover guid as COR_PROFILER.

Our OpenCover integration documentation shows that you need to set only JUSTMOCK_INSTANCE, assuming that OpenCover have set COR_PROFILER and COR_ENABLE_PROFILING. We need to improve that.

I hope that makes sense. Let me know if you have any questions.

Regards,
Svetlozar
Telerik by Progress

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

Josh

I also tried the OpenCover/JustMock integration as specified in the documentation and saw the same error. Does that mean that the Integration isn't working as documented? Should I try specifying the environment variables explicitly, but using the OpenCover GUID this time?

Josh

I tried both ways. First, I specified the OpenCover CLSID Guid explicitly and received the same error. Then, I removed the COR_* environment variables and left only JustMock_Instance=1 set and received the same error.

Telerik.JustMock.Core.ElevatedMockingException : Cannot mock 'System.DateTimeOffset'. The profiler must be enabled to mock, arrange or execute the specified target.

Detected active third-party profilers:

* (from process environment)

Disable the profilers or link them from the JustMock configuration utility. Restart the test runner and, if necessary, Visual Studio after linking.

at Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member)

It looks like passing the register flag resets our linking information. We will need more time to investigate that. Could you please check if that works for you?

Regards,
Svetlozar
Telerik by Progress

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

Josh

Thank you, that worked! I removed the -register:user flag and it worked. I'm keen to understand more about what is going on here. We were originally using the OpenCover NuGet package and switched to the install per the JustMock integration guide. The -register:user flag was vestigial from that original setup. I imagine the path laid out in the Integration guide doesn't work if OpenCover is consumed as a NuGet package, rather than as an install on the build machine?

Svetlozar

That is a great question actually. I just reviewed the OpenCover -register implementation and it turned out to be what I expected. When you pass the register flag, OpenCover does regvr32 for the OpenCover dll. You can view it here - ProfilerRegistration.cs and more specifically - Register and ExecuteRegsvr32

What regsvr32 actually does is to store in registry the profiler dll path with the associated profiler guid so that the CLR can find and load it. Here is where JustMock comes into play, when you 'link' profilers we actually temporarily modify the registry entry and the OpenCover guid points to a JustMock profiler that does JustMock related work and callbacks the OpenCover profiler, the so called linking. When you pass the register flag, regsvr32 is called which overwrites our replaced registry entry and JustMock is not called.

The registry edit is our workaround of the CLR limitation that there could be only one profiler per process.

I hope that makes sense. Let me know if you have any questions.

Regards,
Svetlozar
Telerik by Progress

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

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.