Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Sep 23, 2024
2 parents be0f7d6 + 6793b6b commit b4141a4
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Xml.Linq;
using System.Globalization;
using System.Xml.Linq;
using NuGet.Versioning;
using Serilog;
using Synthesis.Bethesda.Execution.Versioning;
Expand All @@ -15,6 +16,7 @@ public class SwapToProperNetVersion : ISwapToProperNetVersion
private readonly ILogger _logger;
private const int NetNum = 8;
private readonly Version Net8Version = new Version(0, 45);
private readonly CultureInfo Culture = new CultureInfo("en");

public SwapToProperNetVersion(ILogger logger)
{
Expand Down Expand Up @@ -46,18 +48,30 @@ private void ProcessLegacy(XElement elem)
}
}

private void ProcessNet8(XElement elem, Version targetMutagenVersion)
private bool NeedsUpgrade(string elem)
{
if (!elem.Value.StartsWith("net"))
if (elem.StartsWith("netcoreapp", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (!elem.StartsWith("net", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException($"Could not process version: {elem.Value}");
throw new ArgumentException($"Could not process version: {elem}");
}

if (double.TryParse(elem.Value.Substring(3), out var netNum)
if (double.TryParse(elem.Substring(3), Culture, out var netNum)
&& netNum > NetNum)
{
return;
_logger.Information($"Already net{netNum}. No need to upgrade");
return false;
}

return true;
}

private void ProcessNet8(XElement elem, Version targetMutagenVersion)
{
if (!NeedsUpgrade(elem.Value)) return;

_logger.Information("Swapping to net8.0");
elem.Value = $"net{NetNum}.0";
Expand Down

0 comments on commit b4141a4

Please sign in to comment.