Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
kccarter76 committed Aug 16, 2020
1 parent c5674e0 commit 1cc2430
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
22 changes: 22 additions & 0 deletions SubSonic.Core.Extensions.Testing/UtilityTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;

namespace SubSonic.Core.Extensions.Testing
{
[TestFixture]
public class UtilityTests
{
[Test]
[TestCase("netcoreapp3.1", 2.1)]
[TestCase("netcoreapp3.0", 2.1)]
[TestCase("netcoreapp2.1", 2.0)]
[TestCase("net472", 2.0)]
public void GetNetStandardVersionTests(string framework, decimal expectedVersion)
{
Utilities.GetNetStandardVersion(framework).Should().Be(expectedVersion);
}
}
}
23 changes: 21 additions & 2 deletions SubSonic.Core.Extensions/Utilities/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace SubSonic.Core
{
public partial class Utilities
{
public static partial class Utilities
{
private static readonly Regex s_frameworkRegex = new Regex("(?<framework>[a-z]*)(?<major>[0-9]*).(?<minor>[0-9]*)", RegexOptions.Compiled);

public static string FindHighestVersionedDirectory(string parentFolder, Func<string, bool> validate)
{
string bestMatch = null;
Expand All @@ -26,5 +29,21 @@ public static string FindHighestVersionedDirectory(string parentFolder, Func<str
}
return bestMatch;
}

public static decimal GetNetStandardVersion(string framework)
{
var match = s_frameworkRegex.Match(framework);

if (match.Groups["framework"].Value == "netcoreapp")
{
int.TryParse(match.Groups["major"].Value, out int major);

if (major >= 3)
{
return 2.1M;
}
}
return 2.0M;
}
}
}

0 comments on commit 1cc2430

Please sign in to comment.