Skip to content

Commit

Permalink
Revert part of #3422 (Remove PlatformEqtTrace.Instance)
Browse files Browse the repository at this point in the history
Revert part of #3422 (Remove PlatformEqtTrace.Instance)
  • Loading branch information
MarcoRossignoli authored Mar 25, 2022
1 parent 90e9c21 commit 2edb366
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel;
/// </summary>
public static class EqtTrace
{
private static readonly IPlatformEqtTrace TraceImpl = PlatformEqtTrace.Instance;
private static readonly IPlatformEqtTrace TraceImpl = new PlatformEqtTrace();

#if NETFRAMEWORK
public static void SetupRemoteEqtTraceListeners(AppDomain childDomain)
Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.TestPlatform.PlatformAbstractions/Friends.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -445,19 +445,6 @@ private static void UnInitializeTrace()
TraceLevel = TraceLevel.Off;
Source.Switch.Level = SourceLevels.Off;
}

/// <summary>
/// Trace a verbose message.
/// </summary>
/// <param name="message">Trace message.</param>
[Conditional("TRACE")]
internal static void Verbose(string message)
{
if (Instance.ShouldTrace(PlatformTraceLevel.Verbose))
{
Instance.WriteLine(PlatformTraceLevel.Verbose, message);
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ private static bool IsArm64()
// If nativeMachine is IMAGE_FILE_MACHINE_ARM64 it means that we're running on ARM64 architecture device.
return nativeMachine == NativeMethods.IMAGE_FILE_MACHINE_ARM64;
}
catch (Exception ex)
catch
{
PlatformEqtTrace.Verbose($"PlatformEnvironment.IsArm64: Exception during ARM64 machine evaluation, {ex}\n");
// At the moment we cannot log messages inside the Microsoft.TestPlatform.PlatformAbstractions.
// We did an attempt in https://github.com/microsoft/vstest/pull/3422 - 17.2.0-preview-20220301-01 - but we reverted after
// because we broke a scenario where for .NET Framework application inside the test host
// we loaded runner version of Microsoft.TestPlatform.PlatformAbstractions but newer version Microsoft.TestPlatform.ObjectModel(the one close
// to the test container) and the old PlatformAbstractions doesn't contain the methods expected by the new ObjectModel throwing
// a MissedMethodException.
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ private static bool IsArm64()
return IsArm64Executable(currentProcess.MainModule.FileName);
}
}
catch (Exception ex)
catch
{
PlatformEqtTrace.Verbose($"ProcessHelper.IsArm64: Exception during ARM64 process evaluation, {ex}\n");
// At the moment we cannot log messages inside the Microsoft.TestPlatform.PlatformAbstractions.
// We did an attempt in https://github.com/microsoft/vstest/pull/3422 - 17.2.0-preview-20220301-01 - but we reverted after
// because we broke a scenario where for .NET Framework application inside the test host
// we loaded runner version of Microsoft.TestPlatform.PlatformAbstractions but newer version Microsoft.TestPlatform.ObjectModel(the one close
// to the test container) and the old PlatformAbstractions doesn't contain the methods expected by the new ObjectModel throwing
// a MissedMethodException.
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel;
/// We pass through exceptions thrown due to incorrect arguments to <c>EqtTrace</c> methods.
/// Usage: <c>EqtTrace.Info("Here's how to trace info");</c>
/// </summary>
public partial class PlatformEqtTrace : IPlatformEqtTrace
public class PlatformEqtTrace : IPlatformEqtTrace
{
private PlatformTraceLevel _traceLevel = PlatformTraceLevel.Off;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel;
/// We pass through exceptions thrown due to incorrect arguments to <c>EqtTrace</c> methods.
/// Usage: <c>EqtTrace.Info("Here's how to trace info");</c>
/// </summary>
public partial class PlatformEqtTrace : IPlatformEqtTrace
public class PlatformEqtTrace : IPlatformEqtTrace
{
private static readonly object InitLock = new();

Expand Down

0 comments on commit 2edb366

Please sign in to comment.