From 357e158cc7686598a0d1900459e4d9108b73babc Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Wed, 13 Sep 2023 20:44:45 +0200 Subject: [PATCH 1/3] Translatable warning with Codes --- src/Tasks/Copy.cs | 8 ++++---- src/Tasks/Resources/Strings.resx | 8 ++++++++ src/Tasks/Resources/xlf/Strings.cs.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.de.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.es.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.fr.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.it.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.ja.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.ko.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.pl.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.pt-BR.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.ru.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.tr.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.zh-Hans.xlf | 10 ++++++++++ src/Tasks/Resources/xlf/Strings.zh-Hant.xlf | 10 ++++++++++ 15 files changed, 142 insertions(+), 4 deletions(-) diff --git a/src/Tasks/Copy.cs b/src/Tasks/Copy.cs index 68d7f27ddba..1afa2ed5eaa 100644 --- a/src/Tasks/Copy.cs +++ b/src/Tasks/Copy.cs @@ -211,11 +211,11 @@ internal static void RefreshInternalEnvironmentValues() /// If MSBUILDALWAYSRETRY is set, also log useful diagnostic information -- as /// a warning, so it's easily visible. /// - private void LogDiagnostic(string message, params object[] messageArgs) + private void LogDiagnosticFromResource(string messageResourceName, params object[] messageArgs) { if (s_alwaysRetryCopy) { - Log.LogWarning(message, messageArgs); + Log.LogWarningWithCodeFromResources(messageResourceName, messageArgs); } } @@ -823,7 +823,7 @@ private bool DoCopyWithRetries(FileState sourceFileState, FileState destinationF case IOException: // Not clear why we can get one and not the other int code = Marshal.GetHRForException(e); - LogDiagnostic("Got {0} copying {1} to {2} and HR is {3}", e.ToString(), sourceFileState.Name, destinationFileState.Name, code); + LogDiagnosticFromResource("Copy.IOException", e.ToString(), sourceFileState.Name, destinationFileState.Name, code); if (code == NativeMethods.ERROR_ACCESS_DENIED) { // ERROR_ACCESS_DENIED can either mean there's an ACL preventing us, or the file has the readonly bit set. @@ -839,7 +839,7 @@ private bool DoCopyWithRetries(FileState sourceFileState, FileState destinationF } else { - LogDiagnostic("Retrying on ERROR_ACCESS_DENIED because MSBUILDALWAYSRETRY = 1"); + LogDiagnosticFromResource("Copy.RetryingOnAccessDenied"); } } else if (code == NativeMethods.ERROR_INVALID_FILENAME) diff --git a/src/Tasks/Resources/Strings.resx b/src/Tasks/Resources/Strings.resx index 8b337bb2db5..188af7c0462 100644 --- a/src/Tasks/Resources/Strings.resx +++ b/src/Tasks/Resources/Strings.resx @@ -2781,6 +2781,14 @@ MSB3893: Could not use a link to copy "{0}" to "{1}". {StrBegin="MSB3893: "} LOCALIZATION: {0} and {1} are paths. + + MSB3094: "Got {0} copying {1} to {2} and HR is {3}" + {StrBegin="MSB3094: "} LOCALIZATION: {0} is exception.ToString(), {1} and {2} are paths, {3} is a number") + + + "MSB3095: Retrying on ERROR_ACCESS_DENIED because environment variable MSBUILDALWAYSRETRY = 1" + {StrBegin="MSB3095: "} LOCALIZATION: Do NOT translate MSBUILDALWAYSRETRY") +