Merge pull request #39 from nunit/issue-35

Merge pull request #38 from nunit/updt-recipe
This commit is contained in:
CharliePoole 2024-07-16 02:45:11 -07:00 коммит произвёл GitHub
Родитель b104eafd39 0c281c198f
Коммит c56dd796d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -79,7 +79,9 @@ namespace NUnit.Engine.Addins
DateTime start = result.GetAttribute("start-time", DateTime.UtcNow);
_xmlWriter.WriteAttributeString("date", start.ToString("yyyy-MM-dd"));
_xmlWriter.WriteAttributeString("time", start.ToString("HH:mm:ss"));
WriteEnvironment(assemblies[0].SelectSingleNode("environment")?.GetAttribute("framework-version"));
WriteEnvironment(GetFrameworkVersion(assemblies));
WriteCultureInfo();
}
@ -93,6 +95,22 @@ namespace NUnit.Engine.Addins
_xmlWriter.WriteEndElement();
}
private string GetFrameworkVersion(XmlNodeList assemblies)
{
// The nunit2 format requires a framework-version attribute as part of the environment
// element. This was an error in the original V2 design, since the various assemblies
// do not necessarily use the same framework version. To provide some value, we examine
// all the assemblies and return the first non-empty value found.
foreach (XmlNode node in assemblies)
{
var version = node.SelectSingleNode("environment")?.GetAttribute("framework-version");
if (!string.IsNullOrEmpty(version))
return version;
}
return string.Empty;
}
private void WriteEnvironment(string frameworkVersion)
{
_xmlWriter.WriteStartElement("environment");