Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: #153 #158 - [v2] - Add third party extensions #676

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ jobs:
environment_name: ${{ needs.init.outputs.environment_name }}
target_branch_name: ${{ needs.init.outputs.target_branch_name }}
working_directory: 'src'
project_names: 'src/libs/Trakt.NET/Trakt.NET.csproj;src/libs/Trakt.NET.HttpClientFactory/Trakt.NET.HttpClientFactory.csproj'
project_names: 'src/libs/Trakt.NET/Trakt.NET.csproj;src/libs/Trakt.NET.Extensions.TMDB/Trakt.NET.Extensions.TMDB.csproj'
build_configuration: Release
binaries_root_directories: 'src/libs/Trakt.NET/bin;src/libs/Trakt.NET.HttpClientFactory/bin'
binaries_root_directories: 'src/libs/Trakt.NET/bin;src/libs/Trakt.NET.Extensions.TMDB/bin'
artifacts_root_directory: 'artifacts-v2.0.0-alpha'
artifacts_sub_directories: 'netstandard2.0,netstandard2.1,net5.0,net6.0,net7.0,net8.0,net9.0'
artifacts_archive_name: 'Trakt.NET-CI-Build-v2.0.0-Alpha-${{ needs.init.outputs.target_branch_name }}'
Expand Down
1 change: 0 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<LibraryCommonNETPreviewTargets></LibraryCommonNETPreviewTargets>

<LibraryTargetFrameworks>$(LibraryNETStandardTargets);net5.0;$(LibraryCommonNETTargets)</LibraryTargetFrameworks>
<HttpClientFactoryLibraryTargetFrameworks>$(LibraryNETStandardTargets);$(LibraryCommonNETTargets)</HttpClientFactoryLibraryTargetFrameworks>
<TestTargetFrameworks>$(LibraryNETFrameworkTargets);$(LibraryCommonNETTargets)</TestTargetFrameworks>

<!-- These tests use Verify packages which only support these .NET versions >= 6. -->
Expand Down
6 changes: 6 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
</ItemGroup>

<!-- HttpClientFactory Dependencies -->
<ItemGroup Condition="('$(TargetFramework)' == 'net5.0')">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="('$(TargetFramework)' == 'net6.0')">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.2" />
Expand Down
19 changes: 13 additions & 6 deletions src/Trakt.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Trakt.NET.Requests.Tests",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Trakt.NET.Modules.Tests", "tests\libs\Trakt.NET.Modules.Tests\Trakt.NET.Modules.Tests.csproj", "{991F0FB1-CDFD-412E-B7B2-81946E12D6D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Trakt.NET.HttpClientFactory", "libs\Trakt.NET.HttpClientFactory\Trakt.NET.HttpClientFactory.csproj", "{AE64986B-39E8-49C2-A3E0-48FBA888B437}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trakt.NET.Extensions.TMDB", "libs\Trakt.NET.Extensions.TMDB\Trakt.NET.Extensions.TMDB.csproj", "{5E6FE4C0-07D9-010B-E19B-DA162549E9E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trakt.NET.Extensions.TMDB.Tests", "tests\libs\Trakt.NET.Extensions.TMDB.Tests\Trakt.NET.Extensions.TMDB.Tests.csproj", "{CC693155-5F85-4C13-9082-8B9443FB85DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -162,10 +164,14 @@ Global
{991F0FB1-CDFD-412E-B7B2-81946E12D6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{991F0FB1-CDFD-412E-B7B2-81946E12D6D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{991F0FB1-CDFD-412E-B7B2-81946E12D6D7}.Release|Any CPU.Build.0 = Release|Any CPU
{AE64986B-39E8-49C2-A3E0-48FBA888B437}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE64986B-39E8-49C2-A3E0-48FBA888B437}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE64986B-39E8-49C2-A3E0-48FBA888B437}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE64986B-39E8-49C2-A3E0-48FBA888B437}.Release|Any CPU.Build.0 = Release|Any CPU
{5E6FE4C0-07D9-010B-E19B-DA162549E9E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E6FE4C0-07D9-010B-E19B-DA162549E9E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E6FE4C0-07D9-010B-E19B-DA162549E9E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E6FE4C0-07D9-010B-E19B-DA162549E9E3}.Release|Any CPU.Build.0 = Release|Any CPU
{CC693155-5F85-4C13-9082-8B9443FB85DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC693155-5F85-4C13-9082-8B9443FB85DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC693155-5F85-4C13-9082-8B9443FB85DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC693155-5F85-4C13-9082-8B9443FB85DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -196,7 +202,8 @@ Global
{C479E397-69C6-4C3D-BD4D-19C8ECAB74EA} = {7CCCA937-44EC-4C43-9AEC-409BC790022C}
{A5279041-12FE-4DEA-AC60-79B7FFF3D229} = {50AD22EC-EB56-476B-8DCE-4AF2B5BD8B09}
{991F0FB1-CDFD-412E-B7B2-81946E12D6D7} = {50AD22EC-EB56-476B-8DCE-4AF2B5BD8B09}
{AE64986B-39E8-49C2-A3E0-48FBA888B437} = {E7B2A7FC-F550-4546-8F2C-6FC9AA49F6B5}
{5E6FE4C0-07D9-010B-E19B-DA162549E9E3} = {E7B2A7FC-F550-4546-8F2C-6FC9AA49F6B5}
{CC693155-5F85-4C13-9082-8B9443FB85DA} = {50AD22EC-EB56-476B-8DCE-4AF2B5BD8B09}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7025A39E-11A6-4587-98F7-E887B941D5A0}
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Http" />
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains(TRAKT_NETSTANDARD_TARGET))">
<PackageReference Include="System.Text.Json" />
</ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBBackdropSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBBackdropSize
{
Unspecified,

[TraktEnumMember(JsonValue = "w300", DisplayName = "Width 300")]
Width300,

[TraktEnumMember(JsonValue = "w780", DisplayName = "Width 780")]
Width780,

[TraktEnumMember(JsonValue = "w1280", DisplayName = "Width 1280")]
Width1280,

Original
}
}
28 changes: 28 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBLogoSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBLogoSize
{
Unspecified,

[TraktEnumMember(JsonValue = "w45", DisplayName = "Width 45")]
Width45,

[TraktEnumMember(JsonValue = "w92", DisplayName = "Width 92")]
Width92,

[TraktEnumMember(JsonValue = "w154", DisplayName = "Width 154")]
Width154,

[TraktEnumMember(JsonValue = "w185", DisplayName = "Width 185")]
Width185,

[TraktEnumMember(JsonValue = "w300", DisplayName = "Width 300")]
Width300,

[TraktEnumMember(JsonValue = "w500", DisplayName = "Width 500")]
Width500,

Original
}
}
28 changes: 28 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBPosterSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBPosterSize
{
Unspecified,

[TraktEnumMember(JsonValue = "w92", DisplayName = "Width 92")]
Width92,

[TraktEnumMember(JsonValue = "w154", DisplayName = "Width 154")]
Width154,

[TraktEnumMember(JsonValue = "w185", DisplayName = "Width 185")]
Width185,

[TraktEnumMember(JsonValue = "w342", DisplayName = "Width 342")]
Width342,

[TraktEnumMember(JsonValue = "w500", DisplayName = "Width 500")]
Width500,

[TraktEnumMember(JsonValue = "w780", DisplayName = "Width 780")]
Width780,

Original
}
}
19 changes: 19 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBProfileSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBProfileSize
{
Unspecified,

[TraktEnumMember(JsonValue = "w45", DisplayName = "Width 45")]
Width45,

[TraktEnumMember(JsonValue = "w185", DisplayName = "Width 185")]
Width185,

[TraktEnumMember(JsonValue = "h632", DisplayName = "Height 632")]
Height632,

Original
}
}
19 changes: 19 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBStillSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBStillSize
{
Unspecified,

[TraktEnumMember(JsonValue = "w92", DisplayName = "Width 92")]
Width92,

[TraktEnumMember(JsonValue = "w185", DisplayName = "Width 185")]
Width185,

[TraktEnumMember(JsonValue = "w300", DisplayName = "Width 300")]
Width300,

Original
}
}
29 changes: 29 additions & 0 deletions src/libs/Trakt.NET.Extensions.TMDB/Enums/TMDBVideoType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace TraktNET
{
[TraktEnum]
public enum TMDBVideoType
{
Unspecified,

[TraktEnumMember(JsonValue = "Trailer")]
Trailer,

[TraktEnumMember(JsonValue = "Teaser")]
Teaser,

[TraktEnumMember(JsonValue = "Clip")]
Clip,

[TraktEnumMember(JsonValue = "Behind the Scenes", DisplayName = "Behind the Scenes")]
BehindTheScenes,

[TraktEnumMember(JsonValue = "Bloopers")]
Bloopers,

[TraktEnumMember(JsonValue = "Featurette")]
Featurette,

[TraktEnumMember(JsonValue = "Opening Credits")]
OpeningCredits
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TraktNET
{
public sealed partial class TMDBRequestValidationException : Exception
{
/// <summary>The name of the proeprty that caused the current exception.</summary>
public string? PropertyName { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace TraktNET
{
public sealed class TMDBContext : ITraktContext
{
private string _readAccessToken = string.Empty;

public string ID { get; } = Guid.NewGuid().ToString();

public Uri BaseUri { get; internal set; }

internal TMDBContext(string readAccessToken)
{
ReadAccessToken = readAccessToken;
BaseUri = new Uri($"{TMDBConstants.API.BaseURL}{TMDBConstants.API.Version}/");
HttpClientProvider = new TMDBHttpClientProvider();
}

internal string ReadAccessToken
{
get => _readAccessToken;

set
{
ArgumentValidator.ThrowIfNullOrWhiteSpace(value, "read access token must not be null or empty or only whitespace", checkSpaces: true);
_readAccessToken = value;
}
}

internal HttpClientProvider<TMDBContext> HttpClientProvider { get; set; }

internal HttpClient GetHttpClient() => HttpClientProvider.GetHttpClient(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace TraktNET
{
public sealed partial class TMDBRequestValidationException
{
internal TMDBRequestValidationException(string message, Exception? innerException = null) : base(message, innerException)
{
}

internal TMDBRequestValidationException(string propertyName, string message, Exception? innerException = null)
: base(message, innerException)
=> PropertyName = propertyName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace TraktNET
{
[ExcludeFromCodeCoverage]
[JsonSerializable(typeof(TMDBConfiguration))]
[JsonSerializable(typeof(IReadOnlyList<TMDBConfiguration>))]
[JsonSerializable(typeof(TMDBConfigurationImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBConfigurationImages>))]
[JsonSerializable(typeof(TMDBEpisodeImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBEpisodeImages>))]
[JsonSerializable(typeof(TMDBErrorResponse))]
[JsonSerializable(typeof(IReadOnlyList<TMDBErrorResponse>))]
[JsonSerializable(typeof(TMDBImage))]
[JsonSerializable(typeof(IReadOnlyList<TMDBImage>))]
[JsonSerializable(typeof(TMDBMovieImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBMovieImages>))]
[JsonSerializable(typeof(TMDBPersonImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBPersonImages>))]
[JsonSerializable(typeof(TMDBSeasonImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBSeasonImages>))]
[JsonSerializable(typeof(TMDBShowImages))]
[JsonSerializable(typeof(IReadOnlyList<TMDBShowImages>))]
[JsonSerializable(typeof(TMDBVideo))]
[JsonSerializable(typeof(IReadOnlyList<TMDBVideo>))]
[JsonSerializable(typeof(TMDBVideos))]
[JsonSerializable(typeof(IReadOnlyList<TMDBVideos>))]
public sealed partial class TMDBJsonSerializerContext : JsonSerializerContext
{
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#if NET6_0_OR_GREATER
using System.Text.Json;
using System.Text.Json.Serialization;

namespace TraktNET
{
internal sealed class TMDBJsonSerializerContextFactory : IJsonSerializerContextFactory
{
private static readonly TMDBJsonSerializerContext s_jsonSerializerContext = new(new JsonSerializerOptions(TMDBConstants.Json.JsonOptions));

public JsonSerializerContext GetContext<TJsonObjectType>() => s_jsonSerializerContext;
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Concurrent;

namespace TraktNET
{
internal sealed class TMDBHttpClientProvider : HttpClientProvider<TMDBContext>
{
private static readonly ConcurrentDictionary<string, HttpClient> s_httpClientCache = new();

internal override HttpClient GetHttpClient(TMDBContext context)
=> s_httpClientCache.GetOrAdd(context.ID, CreateHttpClient(context));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TraktNET
{
internal abstract class TMDBRequestBase(HttpMethod method, Uri? requestUri) : HttpRequestMessage(method, requestUri)
{
internal abstract void BuildUri();

internal virtual void Validate() { }
}
}
Loading
Loading