Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #120 from aspriddell/netstd2
Browse files Browse the repository at this point in the history
Downgrade to .NET Standard 2.0
  • Loading branch information
aspriddell authored Oct 13, 2020
2 parents 30c0996 + 275e787 commit 99f4f93
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DragonFruit.Six.API.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Threading.Tasks;
using DragonFruit.Six.API.Data.Extensions;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Tests.Common;
using DragonFruit.Six.API.Utils;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand Down
2 changes: 1 addition & 1 deletion DragonFruit.Six.API.Tests.Common/Dragon6DemoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using DragonFruit.Six.API.Developer.Extensions;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Exceptions;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;

namespace DragonFruit.Six.API.Tests.Common
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using DragonFruit.Common.Data.Extensions;
using DragonFruit.Six.API.Data.Containers;
using DragonFruit.Six.API.Data.Strings;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;
using Newtonsoft.Json.Linq;

namespace DragonFruit.Six.API.Data.Deserializers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using DragonFruit.Common.Data.Extensions;
using DragonFruit.Six.API.Data.Containers;
using DragonFruit.Six.API.Data.Strings;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;
using Newtonsoft.Json.Linq;

namespace DragonFruit.Six.API.Data.Deserializers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using DragonFruit.Common.Data.Extensions;
using DragonFruit.Six.API.Data.Strings;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Utils;
using Newtonsoft.Json.Linq;

namespace DragonFruit.Six.API.Data.Deserializers
Expand All @@ -31,7 +32,7 @@ public static SeasonStats DeserializeSeasonStatsFor(this JObject jObject, string
Wins = json.GetUInt(Seasonal.Wins),
Losses = json.GetUInt(Seasonal.Losses),
Abandons = json.GetUInt(Seasonal.Abandons),
WL = json.GetFloat(Seasonal.Wins, 1) / Math.Clamp(json.GetFloat(Seasonal.Losses) + json.GetFloat(Seasonal.Abandons), 1, float.MaxValue),
WL = json.GetFloat(Seasonal.Wins, 1) / MathUtils.Clamp(json.GetFloat(Seasonal.Losses) + json.GetFloat(Seasonal.Abandons), 1, float.MaxValue),

Rank = json.GetUInt(Seasonal.Rank),
MaxRank = json.GetUInt(Seasonal.MaxRank),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using DragonFruit.Six.API.Data.Containers;
using DragonFruit.Six.API.Data.Strings;
using DragonFruit.Six.API.Data.Tokens;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;
using Newtonsoft.Json.Linq;

namespace DragonFruit.Six.API.Data.Deserializers
Expand Down
8 changes: 4 additions & 4 deletions DragonFruit.Six.API/Data/Requests/AccountInfoRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using DragonFruit.Common.Data.Parameters;
using DragonFruit.Six.API.Data.Requests.Base;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;

namespace DragonFruit.Six.API.Data.Requests
{
Expand Down Expand Up @@ -43,12 +43,12 @@ public AccountInfoRequest(Platform platform, LookupMethod lookupMethod, IEnumera
public string PlatformValue => PlatformParser.PlatformIdentifierFor(Platform);

[QueryParameter("nameOnPlatform")]
public string PlayerNames => LookupMethod == LookupMethod.Name ? string.Join(',', LookupQuery) : null;
public string PlayerNames => LookupMethod == LookupMethod.Name ? string.Join(",", LookupQuery) : null;

[QueryParameter("idOnPlatform")]
public string PlatformIds => LookupMethod == LookupMethod.PlatformId ? string.Join(',', LookupQuery) : null;
public string PlatformIds => LookupMethod == LookupMethod.PlatformId ? string.Join(",", LookupQuery) : null;

[QueryParameter("userId")]
public string UbisoftIds => LookupMethod == LookupMethod.UserId ? string.Join(',', LookupQuery) : null;
public string UbisoftIds => LookupMethod == LookupMethod.UserId ? string.Join(",", LookupQuery) : null;
}
}
6 changes: 3 additions & 3 deletions DragonFruit.Six.API/Data/Requests/AccountLoginInfoRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;
using DragonFruit.Common.Data.Parameters;
using DragonFruit.Six.API.Data.Requests.Base;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;

namespace DragonFruit.Six.API.Data.Requests
{
Expand All @@ -29,9 +29,9 @@ public AccountLoginInfoRequest(IEnumerable<AccountInfo> profiles)
public IEnumerable<AccountInfo> Accounts { get; set; }

[QueryParameter("applicationIds")]
public string AppIdString => string.Join(',', AppIds);
public string AppIdString => string.Join(",", AppIds);

[QueryParameter("profileIds")]
public string ProfileIdString => string.Join(',', Accounts.Select(x => x.Identifiers.Profile));
public string ProfileIdString => string.Join(",", Accounts.Select(x => x.Identifiers.Profile));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public BasicStatsRequest(IEnumerable<AccountInfo> accounts)
public override string AccountIdString => base.AccountIdString;

[QueryParameter("statistics")]
public string CompiledStats => string.Join(',', Stats);
public string CompiledStats => string.Join(",", Stats);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected PlatformSpecificRequest(IEnumerable<AccountInfo> accounts)

public IEnumerable<string> AccountIds => Accounts.Select(x => x.Identifiers.Profile);

public virtual string AccountIdString => string.Join(',', AccountIds);
public virtual string AccountIdString => string.Join(",", AccountIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public PlayerLevelStatsRequest(IEnumerable<AccountInfo> accounts)
}

[QueryParameter("profile_ids")]
public string CompiledAccounts => string.Join(',', Accounts.Select(x => x.Identifiers.Profile));
public string CompiledAccounts => string.Join(",", Accounts.Select(x => x.Identifiers.Profile));
}
}
2 changes: 1 addition & 1 deletion DragonFruit.Six.API/Data/Requests/SeasonStatsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public SeasonStatsRequest(IEnumerable<AccountInfo> accounts, int seasonId, strin
public string Region { get; set; } = "EMEA";

[QueryParameter("profile_ids")]
public string CompiledAccounts => string.Join(',', Accounts.Select(x => x.Identifiers.Profile));
public string CompiledAccounts => string.Join(",", Accounts.Select(x => x.Identifiers.Profile));
}
}
2 changes: 1 addition & 1 deletion DragonFruit.Six.API/Dragon6Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using DragonFruit.Six.API.Data.Tokens;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Exceptions;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;

namespace DragonFruit.Six.API
{
Expand Down
3 changes: 2 additions & 1 deletion DragonFruit.Six.API/DragonFruit.Six.API.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>DragonFruit.Six.API</AssemblyName>
<RootNamespace>DragonFruit.Six.API</RootNamespace>
<PackageId>Dragon6.API</PackageId>
Expand All @@ -17,6 +17,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>r6stats, r6api, r6, rainbowsix</PackageTags>
<Authors>DragonFruit Network</Authors>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion DragonFruit.Six.API/Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using DragonFruit.Six.API.Enums;
using DragonFruit.Six.API.Helpers;
using DragonFruit.Six.API.Utils;

namespace DragonFruit.Six.API
{
Expand Down
77 changes: 77 additions & 0 deletions DragonFruit.Six.API/Utils/MathUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network>
// Licensed under Apache-2. Please refer to the LICENSE file for more info

using System;
using System.Runtime.CompilerServices;

namespace DragonFruit.Six.API.Utils
{
/// <summary>
/// Functions from the <see cref="Math"/> class from .NET Standard 2
/// </summary>
/// <remarks>
/// Taken from https://source.dot.net/#System.Private.CoreLib/Math.cs (MIT)
/// </remarks>
internal static class MathUtils
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Clamp(double value, double min, double max)
{
if (min > max)
{
throw new ArgumentException();
}

if (value < min)
{
return min;
}
else if (value > max)
{
return max;
}

return value;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Clamp(int value, int min, int max)
{
if (min > max)
{
throw new ArgumentException();
}

if (value < min)
{
return min;
}
else if (value > max)
{
return max;
}

return value;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Clamp(float value, float min, float max)
{
if (min > max)
{
throw new ArgumentException();
}

if (value < min)
{
return min;
}
else if (value > max)
{
return max;
}

return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using DragonFruit.Six.API.Enums;
using Newtonsoft.Json.Linq;

namespace DragonFruit.Six.API.Helpers
namespace DragonFruit.Six.API.Utils
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static class OperatorData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using DragonFruit.Six.API.Enums;

namespace DragonFruit.Six.API.Helpers
namespace DragonFruit.Six.API.Utils
{
public static class PlatformParser
{
Expand All @@ -14,7 +14,7 @@ public static class PlatformParser
/// </summary>
public static Platform GetPlatform(string platformId)
{
return Enum.Parse<Platform>(platformId, true);
return (Platform)Enum.Parse(typeof(Platform), platformId, true);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using DragonFruit.Six.API.Enums;

namespace DragonFruit.Six.API.Helpers
namespace DragonFruit.Six.API.Utils
{
public static class UbisoftIdentifiers
{
Expand Down

0 comments on commit 99f4f93

Please sign in to comment.