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

remove redundant string interpolation #4571

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions samples/Playground/DebuggerUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private static bool AttachVSToProcess(int? pid, int? vsPid, bool enableLog = fal
{
if (pid == null)
{
Trace($"FAIL: Pid is null.", enabled: enableLog);
Trace("FAIL: Pid is null.", enabled: enableLog);
return false;
}

Expand All @@ -37,7 +37,7 @@ private static bool AttachVSToProcess(int? pid, int? vsPid, bool enableLog = fal
return true;
}

Trace($"Parent VS not found, finding the first VS that started.", enabled: enableLog);
Trace("Parent VS not found, finding the first VS that started.", enabled: enableLog);
Process? firstVsProcess = GetFirstVsProcess();

if (firstVsProcess != null)
Expand Down Expand Up @@ -122,21 +122,21 @@ private static bool AttachVs(Process vs, int pid, bool enableLog = false)
Marshal.ThrowExceptionForHR(r);
if (bindCtx == null)
{
Trace($"BindCtx is null. Cannot attach VS.", enabled: enableLog);
Trace("BindCtx is null. Cannot attach VS.", enabled: enableLog);
return false;
}

bindCtx.GetRunningObjectTable(out runningObjectTable);
if (runningObjectTable == null)
{
Trace($"RunningObjectTable is null. Cannot attach VS.", enabled: enableLog);
Trace("RunningObjectTable is null. Cannot attach VS.", enabled: enableLog);
return false;
}

runningObjectTable.EnumRunning(out enumMoniker);
if (enumMoniker == null)
{
Trace($"EnumMoniker is null. Cannot attach VS.", enabled: enableLog);
Trace("EnumMoniker is null. Cannot attach VS.", enabled: enableLog);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ await _namedPipeClient.RequestReplyAsync<ConsumerPipeNameRequest, VoidResponse>(

// Wait the connection from the testhost controller
await _singleConnectionNamedPipeServer.WaitConnectionAsync(cancellationToken).TimeoutAfterAsync(TimeoutHelper.DefaultHangTimeSpanTimeout, cancellationToken);
await _logger.LogTraceAsync($"Test host controller connected");
await _logger.LogTraceAsync("Test host controller connected");
}
catch (OperationCanceledException ex) when (ex.CancellationToken == cancellationToken)
{
Expand Down Expand Up @@ -224,7 +224,7 @@ private Task SignalActivityIndicatorAsync()
_signalActivity.Reset();
}

_logger.LogDebug($"Exit 'SignalActivityIndicatorAsync'");
_logger.LogDebug("Exit 'SignalActivityIndicatorAsync'");

return Task.CompletedTask;
}
Expand All @@ -242,10 +242,10 @@ public async Task OnTestSessionFinishingAsync(SessionUid sessionUid, Cancellatio
await _namedPipeClient.RequestReplyAsync<SessionEndSerializerRequest, VoidResponse>(new SessionEndSerializerRequest(), cancellationToken)
.TimeoutAfterAsync(TimeoutHelper.DefaultHangTimeSpanTimeout, cancellationToken);

await _logger.LogDebugAsync($"Signal for test session end'");
await _logger.LogDebugAsync("Signal for test session end'");
await ExitSignalActivityIndicatorTaskAsync();

await _logger.LogTraceAsync($"Signaled by process for it's exit");
await _logger.LogTraceAsync("Signaled by process for it's exit");
_sessionEndCalled = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private async Task<IResponse> CallbackAsync(IRequest request)
}
else if (request is SessionEndSerializerRequest)
{
await _logger.LogDebugAsync($"Session end received by the test host");
await _logger.LogDebugAsync("Session end received by the test host");
_exitActivityIndicatorTask = true;
#if NET
if (_namedPipeClient is not null)
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task OnTestHostProcessExitedAsync(ITestHostProcessInformation testH

private async Task ActivityTimerAsync()
{
_logger.LogDebug($"Wait for mutex name from the test host");
_logger.LogDebug("Wait for mutex name from the test host");

if (!_mutexNameReceived.Wait(TimeoutHelper.DefaultHangTimeSpanTimeout))
{
Expand All @@ -244,7 +244,7 @@ private async Task ActivityTimerAsync()
{
if (_traceEnabled)
{
_logger.LogTrace($"Wait for activity signal");
_logger.LogTrace("Wait for activity signal");
}

if (!_activityIndicatorMutex.WaitOne(_activityTimerValue))
Expand All @@ -271,7 +271,7 @@ private async Task ActivityTimerAsync()

if (_traceEnabled)
{
_logger.LogTrace($"Exit 'ActivityTimerAsync'");
_logger.LogTrace("Exit 'ActivityTimerAsync'");
}
}
catch (AbandonedMutexException)
Expand All @@ -290,7 +290,7 @@ private async Task ActivityTimerAsync()
{
try
{
_logger.LogDebug($"Timeout is not fired release activity mutex handle to allow test host to close");
_logger.LogDebug("Timeout is not fired release activity mutex handle to allow test host to close");
_activityIndicatorMutex.ReleaseMutex();
}
catch (AbandonedMutexException)
Expand All @@ -306,7 +306,7 @@ private async Task ActivityTimerAsync()
}

_activityIndicatorMutex.Dispose();
_logger.LogDebug($"Activity indicator disposed");
_logger.LogDebug("Activity indicator disposed");

if (timeoutFired)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public async Task<int> OrchestrateTestHostExecutionAsync()
using (var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(timeout.Token, _serviceProvider.GetTestApplicationCancellationTokenSource().CancellationToken))
using (var linkedToken2 = CancellationTokenSource.CreateLinkedTokenSource(linkedToken.Token, processExitedCancellationToken.Token))
{
await logger.LogDebugAsync($"Wait connection from the test host process");
await logger.LogDebugAsync("Wait connection from the test host process");
try
{
#if NETCOREAPP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private async Task IngestLoopAsync()
{
_client = null;

await _logger.LogErrorAsync($"Failed to initialize telemetry client", e);
await _logger.LogErrorAsync("Failed to initialize telemetry client", e);
return;
}

Expand Down Expand Up @@ -219,7 +219,7 @@ private async Task IngestLoopAsync()
// We could do better back-pressure.
if (_logger.IsEnabled(LogLevel.Error) && (!lastLoggedError.HasValue || (lastLoggedError.Value - _clock.UtcNow).TotalSeconds > 3))
{
await _logger.LogErrorAsync($"Error during telemetry report.", ex);
await _logger.LogErrorAsync("Error during telemetry report.", ex);
lastLoggedError = _clock.UtcNow;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override bool Execute()
Log.LogMessage(MessageImportance.Normal, $"Microsoft Testing Platform configuration file: '{TestingPlatformConfigurationFileSource.ItemSpec}'");
if (!_fileSystem.Exist(TestingPlatformConfigurationFileSource.ItemSpec))
{
Log.LogMessage(MessageImportance.Normal, $"Microsoft Testing Platform configuration file not found");
Log.LogMessage(MessageImportance.Normal, "Microsoft Testing Platform configuration file not found");
return true;
}

Expand All @@ -62,7 +62,7 @@ public override bool Execute()
Log.LogMessage(MessageImportance.Normal, $"Configuration file found: '{TestingPlatformConfigurationFileSource.ItemSpec}'");
_fileSystem.CopyFile(TestingPlatformConfigurationFileSource.ItemSpec, finalFileName);
FinalTestingPlatformConfigurationFile = new TaskItem(finalFileName);
Log.LogMessage(MessageImportance.Normal, $"Microsoft Testing Platform configuration file written");
Log.LogMessage(MessageImportance.Normal, "Microsoft Testing Platform configuration file written");

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public bool TryGetDotnetPathByArchitecture(
if ((envVar == null || !Directory.Exists(envVar)) &&
targetArchitecture == PlatformArchitecture.X86 && isWinOs)
{
envKey = $"DOTNET_ROOT(x86)";
envKey = "DOTNET_ROOT(x86)";
envVar = Environment.GetEnvironmentVariable(envKey);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public bool TryGetDotnetPathByArchitecture(
}
}

_resolutionLog($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found using DOTNET_ROOT* env variables.");
_resolutionLog("DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found using DOTNET_ROOT* env variables.");

// Try to search for global registration
muxerPath = isWinOs ? GetMuxerFromGlobalRegistrationWin(targetArchitecture) : GetMuxerFromGlobalRegistrationOnUnix(targetArchitecture);
Expand All @@ -151,7 +151,7 @@ public bool TryGetDotnetPathByArchitecture(
return true;
}

_resolutionLog($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer not found using global registrations");
_resolutionLog("DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer not found using global registrations");

// Try searching in default installation location if it exists
if (isWinOs)
Expand Down Expand Up @@ -219,22 +219,22 @@ public bool TryGetDotnetPathByArchitecture(
using var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
if (hklm == null)
{
_resolutionLog($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing SOFTWARE\dotnet\Setup\InstalledVersions subkey");
_resolutionLog(@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing SOFTWARE\dotnet\Setup\InstalledVersions subkey");
return null;
}

using RegistryKey? dotnetInstalledVersion = hklm.OpenSubKey(@"SOFTWARE\dotnet\Setup\InstalledVersions");
if (dotnetInstalledVersion == null)
{
_resolutionLog($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing RegistryHive.LocalMachine for RegistryView.Registry32");
_resolutionLog(@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing RegistryHive.LocalMachine for RegistryView.Registry32");
return null;
}

using RegistryKey? nativeArch = dotnetInstalledVersion.OpenSubKey(targetArchitecture.ToString().ToLowerInvariant());
string? installLocation = nativeArch?.GetValue("InstallLocation")?.ToString();
if (installLocation == null)
{
_resolutionLog($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing registry InstallLocation");
_resolutionLog(@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing registry InstallLocation");
return null;
}

Expand Down Expand Up @@ -307,7 +307,7 @@ public bool TryGetDotnetPathByArchitecture(
// Check if the offset is invalid
if (peHeader > fs.Length - 5)
{
resolutionLog($"[GetMuxerArchitectureByPEHeaderOnWin]Invalid offset");
resolutionLog("[GetMuxerArchitectureByPEHeaderOnWin]Invalid offset");
validImage = false;
}

Expand All @@ -321,7 +321,7 @@ public bool TryGetDotnetPathByArchitecture(
if (reader.ReadUInt32() != 0x00004550)
{
validImage = false;
resolutionLog($"[GetMuxerArchitectureByPEHeaderOnWin]Missing PE signature");
resolutionLog("[GetMuxerArchitectureByPEHeaderOnWin]Missing PE signature");
}

if (validImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static string GetEntryPointSourceCode(string language)
{
if (language == CSharpLanguageSymbol)
{
return $$"""
return """
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Microsoft.Testing.Platform.MSBuild
Expand All @@ -96,7 +96,7 @@ internal sealed class TestingPlatformEntryPoint
}
else if (language == VBLanguageSymbol)
{
return $$"""
return """
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by Microsoft.Testing.Platform.MSBuild
Expand All @@ -123,7 +123,7 @@ End Module
}
else if (language == FSharpLanguageSymbol)
{
return $$"""
return """
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Microsoft.Testing.Platform.MSBuild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static async Task LogInformationAsync(
}
else
{
await logger.LogInformationAsync($"Version attribute not found");
await logger.LogInformationAsync("Version attribute not found");
}

await logger.LogInformationAsync("Logging mode: " + (syncWrite ? "synchronous" : "asynchronous"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected override async Task<int> InternalRunAsync()
string testHostProcessStartupTime = _clock.UtcNow.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture);
processStartInfo.EnvironmentVariables.Add($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_TESTHOSTPROCESSSTARTTIME}_{currentPID}", testHostProcessStartupTime);
await _logger.LogDebugAsync($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_TESTHOSTPROCESSSTARTTIME}_{currentPID} '{testHostProcessStartupTime}'");
await _logger.LogDebugAsync($"Starting test host process");
await _logger.LogDebugAsync("Starting test host process");
using IProcess testHostProcess = process.Start(processStartInfo);

int? testHostProcessId = null;
Expand All @@ -250,7 +250,7 @@ protected override async Task<int> InternalRunAsync()
using (CancellationTokenSource timeout = new(TimeSpan.FromSeconds(timeoutSeconds)))
using (var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(timeout.Token, abortRun))
{
await _logger.LogDebugAsync($"Wait connection from the test host process");
await _logger.LogDebugAsync("Wait connection from the test host process");
await testHostControllerIpc.WaitConnectionAsync(linkedToken.Token);
}

Expand All @@ -260,7 +260,7 @@ protected override async Task<int> InternalRunAsync()
_waitForPid.Wait(timeout.Token);
}

await _logger.LogDebugAsync($"Fire OnTestHostProcessStartedAsync");
await _logger.LogDebugAsync("Fire OnTestHostProcessStartedAsync");

if (_testHostPID is null)
{
Expand All @@ -279,7 +279,7 @@ protected override async Task<int> InternalRunAsync()
}
}

await _logger.LogDebugAsync($"Wait for test host process exit");
await _logger.LogDebugAsync("Wait for test host process exit");
await testHostProcess.WaitForExitAsync();

if (_testHostsInformation.LifetimeHandlers.Length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal event EventHandler OnProgressStopUpdate
#if NET7_0_OR_GREATER
// Specifying no timeout, the regex is linear. And the timeout does not measure the regex only, but measures also any
// thread suspends, so the regex gets blamed incorrectly.
[GeneratedRegex(@$"^ at ((?<code>.+) in (?<file>.+):line (?<line>\d+)|(?<code1>.+))$", RegexOptions.ExplicitCapture)]
[GeneratedRegex(@"^ at ((?<code>.+) in (?<file>.+):line (?<line>\d+)|(?<code1>.+))$", RegexOptions.ExplicitCapture)]
private static partial Regex GetFrameRegex();
#else
private static Regex? s_regex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Microsoft.Testing.Platform.Telemetry;

internal static class TelemetryProperties
{
public const string VersionPropertyName = $"telemetry version";
public const string VersionPropertyName = "telemetry version";
public const string SessionId = "session id";
public const string ReporterIdPropertyName = $"reporter id";
public const string ReporterIdPropertyName = "reporter id";
public const string IsCIPropertyName = "is ci";

public const string VersionValue = "19";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public async Task NativeAot_Smoke_Test_Windows()
// temporarily set test to be on net9.0 as it's fixing one error that started to happen: error IL3000: System.Net.Quic.MsQuicApi..cctor
// see https://github.com/dotnet/sdk/issues/44880.
.PatchCodeWithReplace("$TargetFramework$", "net9.0")
.PatchCodeWithReplace("$ExtraProperties$", $"""
.PatchCodeWithReplace("$ExtraProperties$", """
<PublishAot>true</PublishAot>
<EnableMicrosoftTestingExtensionsCodeCoverage>false</EnableMicrosoftTestingExtensionsCodeCoverage>
"""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public async Task DiscoverAndRun(string tfm)
ResponseListener runListener = await jsonClient.RunTests(Guid.NewGuid(), runCollector.CollectNodeUpdates);

await Task.WhenAll(discoveryListener.WaitCompletion(), runListener.WaitCompletion());
Assert.AreEqual(1, discoveryCollector.TestNodeUpdates.Count(x => x.Node.NodeType == "action"), $"Wrong number of discovery");
Assert.AreEqual(2, runCollector.TestNodeUpdates.Count, $"Wrong number of updates");
Assert.AreNotEqual(0, logs.Count, $"Logs are empty");
Assert.IsFalse(telemetry.IsEmpty, $"telemetry is empty");
Assert.AreEqual(1, discoveryCollector.TestNodeUpdates.Count(x => x.Node.NodeType == "action"), "Wrong number of discovery");
Assert.AreEqual(2, runCollector.TestNodeUpdates.Count, "Wrong number of updates");
Assert.AreNotEqual(0, logs.Count, "Logs are empty");
Assert.IsFalse(telemetry.IsEmpty, "telemetry is empty");
await jsonClient.Exit();
Assert.AreEqual(0, await jsonClient.WaitServerProcessExit());
Assert.AreEqual(0, jsonClient.ExitCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ .NET Testing Platform v.+ \[.+\]
Version: .+
Dynamic Code Supported: True
Runtime information: .+
{(tfm != TargetFrameworks.NetFramework[0] ? "###SKIP###" : $"Runtime location: .+")}
{(tfm != TargetFrameworks.NetFramework[0] ? "###SKIP###" : "Runtime location: .+")}
Test module: .+{TestAssetFixture.NoExtensionAssetName}.*
Built-in command line providers:
PlatformCommandLineProvider
Expand Down Expand Up @@ -392,7 +392,7 @@ .NET Testing Platform v* [*]
Version: *
Dynamic Code Supported: True
Runtime information: *
{(tfm != TargetFrameworks.NetFramework[0] ? "###SKIP###" : $"Runtime location: *")}
{(tfm != TargetFrameworks.NetFramework[0] ? "###SKIP###" : "Runtime location: *")}
Test module: *{TestAssetFixture.AllExtensionsAssetName}*
Built-in command line providers:
PlatformCommandLineProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ await DotnetCli.RunAsync(
environmentVariables: dotnetRootX86,
failIfReturnValueIsNotZero: false);

string outputFileLog = Directory.GetFiles(testAsset.TargetAssetPath, $"MSBuild Tests_net9.0_x86.log", SearchOption.AllDirectories).Single();
string outputFileLog = Directory.GetFiles(testAsset.TargetAssetPath, "MSBuild Tests_net9.0_x86.log", SearchOption.AllDirectories).Single();
Assert.IsTrue(File.Exists(outputFileLog), $"Expected file '{outputFileLog}'");
string logFileContent = File.ReadAllText(outputFileLog);
Assert.IsTrue(Regex.IsMatch(logFileContent, ".*win-x86.*"), logFileContent);
Expand Down
Loading
Loading