parent
0c3dcdf77b
commit
6f8ccab788
@ -1,12 +1,19 @@
|
|||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Sorting
|
namespace Jellyfin.Extensions
|
||||||
{
|
{
|
||||||
public class AlphanumComparator : IComparer<string?>
|
/// <summary>
|
||||||
|
/// Alphanumeric <see cref="IComparer{T}" />.
|
||||||
|
/// </summary>
|
||||||
|
public class AlphanumericComparator : IComparer<string?>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s1">The first object to compare.</param>
|
||||||
|
/// <param name="s2">The second object to compare.</param>
|
||||||
|
/// <returns>A signed integer that indicates the relative values of <c>x</c> and <c>y</c>.</returns>
|
||||||
public static int CompareValues(string? s1, string? s2)
|
public static int CompareValues(string? s1, string? s2)
|
||||||
{
|
{
|
||||||
if (s1 == null && s2 == null)
|
if (s1 == null && s2 == null)
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Extensions
|
namespace Jellyfin.Extensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
|
/// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
|
@ -0,0 +1,30 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
||||||
|
<CodeAnalysisRuleSet>../../jellyfin.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Authors>Jellyfin Contributors</Authors>
|
||||||
|
<RepositoryUrl>https://github.com/jellyfin/jellyfin</RepositoryUrl>
|
||||||
|
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="../../SharedVersion.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Code Analyzers-->
|
||||||
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,8 +1,8 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using MediaBrowser.Common.Json.Converters;
|
using Jellyfin.Extensions.Json.Converters;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Json
|
namespace Jellyfin.Extensions.Json
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper class for having compatible JSON throughout the codebase.
|
/// Helper class for having compatible JSON throughout the codebase.
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Extensions
|
namespace Jellyfin.Extensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides <c>Shuffle</c> extensions methods for <see cref="IList{T}" />.
|
/// Provides <c>Shuffle</c> extensions methods for <see cref="IList{T}" />.
|
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Jellyfin.Extensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides extensions methods for <see cref="string" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Counts the number of occurrences of [needle] in the string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The haystack to search in.</param>
|
||||||
|
/// <param name="needle">The character to search for.</param>
|
||||||
|
/// <returns>The number of occurrences of the [needle] character.</returns>
|
||||||
|
public static int Count(this ReadOnlySpan<char> value, char needle)
|
||||||
|
{
|
||||||
|
var count = 0;
|
||||||
|
var length = value.Length;
|
||||||
|
for (var i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if (value[i] == needle)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Common.Extensions;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Common.Tests.Extensions
|
namespace Jellyfin.Extensions.Tests
|
||||||
{
|
{
|
||||||
public static class CopyToExtensionsTests
|
public static class CopyToExtensionsTests
|
||||||
{
|
{
|
@ -0,0 +1,38 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
||||||
|
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="1.3.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Code Analyzers -->
|
||||||
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../../MediaBrowser.Model/MediaBrowser.Model.csproj" />
|
||||||
|
<ProjectReference Include="../../src/Jellyfin.Extensions/Jellyfin.Extensions.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using MediaBrowser.Common.Json.Converters;
|
using Jellyfin.Extensions.Json.Converters;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Common.Tests.Json
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||||||
{
|
{
|
||||||
public class JsonGuidConverterTests
|
public class JsonGuidConverterTests
|
||||||
{
|
{
|
@ -1,9 +1,10 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using Jellyfin.Extensions.Json.Converters;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Model.Tests.Entities
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||||||
{
|
{
|
||||||
public class JsonLowerCaseConverterTests
|
public class JsonLowerCaseConverterTests
|
||||||
{
|
{
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using MediaBrowser.Common.Json.Converters;
|
using Jellyfin.Extensions.Json.Converters;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Common.Tests.Json
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||||||
{
|
{
|
||||||
public class JsonNullableGuidConverterTests
|
public class JsonNullableGuidConverterTests
|
||||||
{
|
{
|
@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using MediaBrowser.Common.Extensions;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Common.Tests.Extensions
|
namespace Jellyfin.Extensions.Tests
|
||||||
{
|
{
|
||||||
public static class ShuffleExtensionsTests
|
public static class ShuffleExtensionsTests
|
||||||
{
|
{
|
@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using MediaBrowser.Controller.Extensions;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Controller.Extensions.Tests
|
namespace Jellyfin.Extensions.Tests
|
||||||
{
|
{
|
||||||
public class StringExtensionsTests
|
public class StringExtensionsTests
|
||||||
{
|
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue