From 5ce04983ad4528648f0e9703796502840164c9a7 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 10 Oct 2024 11:23:05 +0200 Subject: [PATCH] Avoid using string.Format with null args --- src/Controls/src/Build.Tasks/BuildException.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Controls/src/Build.Tasks/BuildException.cs b/src/Controls/src/Build.Tasks/BuildException.cs index e54f266069bd..b763e28d0160 100644 --- a/src/Controls/src/Build.Tasks/BuildException.cs +++ b/src/Controls/src/Build.Tasks/BuildException.cs @@ -30,7 +30,12 @@ protected BuildException(System.Runtime.Serialization.SerializationInfo info, Sy static string FormatMessage(BuildExceptionCode code, IXmlLineInfo xmlinfo, object[] args) { - var message = string.Format(ErrorMessages.ResourceManager.GetString(code.ErrorMessageKey), args); + var message = ErrorMessages.ResourceManager.GetString(code.ErrorMessageKey); + if (args is not null) + { + message = string.Format(message, args); + } + var ecode = code.Code; var position = xmlinfo == null || !xmlinfo.HasLineInfo() ? "" : $"({xmlinfo.LineNumber},{xmlinfo.LinePosition})";