Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert part of #3422 (Remove PlatformEqtTrace.Instance) #3518

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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