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

Feature : Add Net 8.0 #876

Merged
merged 8 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 21 additions & 32 deletions src/Akavache.Core/Akavache.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,74 +1,68 @@
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid12.0;MonoAndroid12.1;MonoAndroid13.0;tizen40;net6.0;net7.0;net7.0-android;net7.0-ios;net7.0-tvos;net7.0-macos;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0</TargetFrameworks>
<TargetFrameworks>$(AkavacheTargetFrameworks)</TargetFrameworks>
<AssemblyName>Akavache.Core</AssemblyName>
<RootNamespace>Akavache</RootNamespace>
<Description>An asynchronous, persistent key-value store for desktop and mobile applications on .NET</Description>
<PackageId>akavache.core</PackageId>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Using Remove="Foundation" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="Splat" Version="14.*" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
<Using Remove="Foundation" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Platforms\**\*.cs" />
<None Include="Platforms\**\*.cs" />
<Compile Include="Platforms\shared\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" !$(TargetFramework.StartsWith('uap'))">
<Compile Include="Platforms\shared-not-uwp\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('uap')) ">
<Compile Include="Platforms\uap\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-ios')) or $(TargetFramework.StartsWith('net7.0-ios')) ">
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.TVOS'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.TVOS')) ">
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="netstandard" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('tizen40'))">
<Compile Include="Platforms\tizen\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-tvos')) or $(TargetFramework.StartsWith('net7.0-tvos')) ">
<ItemGroup Condition="$(TargetFramework.EndsWith('0-ios'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-maccatalyst')) or $(TargetFramework.StartsWith('net7.0-maccatalyst')) ">
<ItemGroup Condition="$(TargetFramework.EndsWith('0-tvos'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.Mac')) ">
<ItemGroup Condition="$(TargetFramework.EndsWith('0-maccatalyst'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="netstandard" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-macos')) or $(TargetFramework.StartsWith('net7.0-macos')) ">
<ItemGroup Condition="$(TargetFramework.EndsWith('0-macos'))">
<Compile Include="Platforms\apple-common\**\*.cs" />
</ItemGroup>

Expand All @@ -78,16 +72,11 @@
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-android')) or $(TargetFramework.StartsWith('net7.0-android')) ">
<ItemGroup Condition="$(TargetFramework.EndsWith('0-android'))">
<Compile Include="Platforms\android\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen40')) ">
<Compile Include="Platforms\tizen\**\*.cs" />
<Compile Include="Platforms\xamarin-mobile\**\*.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="Platforms\shared\DefaultAkavacheHttpClientFactory.cs" />
</ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions src/Akavache.Core/BlobCache/BlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Reactive.Threading.Tasks;

using Newtonsoft.Json.Bson;

using Splat;

namespace Akavache;
Expand Down
33 changes: 13 additions & 20 deletions src/Akavache.Core/BlobCache/CacheEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand All @@ -8,40 +8,33 @@ namespace Akavache;
/// <summary>
/// A entry in a memory cache.
/// </summary>
public class CacheEntry
/// <remarks>
/// Initializes a new instance of the <see cref="CacheEntry"/> class.
/// </remarks>
/// <param name="typeName">The name of the type being stored.</param>
/// <param name="value">The value being stored.</param>
/// <param name="createdAt">The date and time the entry was created.</param>
/// <param name="expiresAt">The date and time when the entry expires.</param>
public class CacheEntry(string? typeName, byte[] value, DateTimeOffset createdAt, DateTimeOffset? expiresAt)
{
/// <summary>
/// Initializes a new instance of the <see cref="CacheEntry"/> class.
/// </summary>
/// <param name="typeName">The name of the type being stored.</param>
/// <param name="value">The value being stored.</param>
/// <param name="createdAt">The date and time the entry was created.</param>
/// <param name="expiresAt">The date and time when the entry expires.</param>
public CacheEntry(string? typeName, byte[] value, DateTimeOffset createdAt, DateTimeOffset? expiresAt)
{
TypeName = typeName;
Value = value;
CreatedAt = createdAt;
ExpiresAt = expiresAt;
}

/// <summary>
/// Gets or sets the date and time when the entry was created.
/// </summary>
public DateTimeOffset CreatedAt { get; protected set; }
public DateTimeOffset CreatedAt { get; protected set; } = createdAt;

/// <summary>
/// Gets or sets the date and time when the entry will expire.
/// </summary>
public DateTimeOffset? ExpiresAt { get; protected set; }
public DateTimeOffset? ExpiresAt { get; protected set; } = expiresAt;

/// <summary>
/// Gets or sets the type name of the entry.
/// </summary>
public string? TypeName { get; protected set; }
public string? TypeName { get; protected set; } = typeName;

/// <summary>
/// Gets or sets the value of the entry.
/// </summary>
public byte[] Value { get; protected set; }
public byte[] Value { get; protected set; } = value;
}
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/IBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/IBulkBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/IObjectBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/IObjectBulkBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/IObjectWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/BlobCache/ISecureBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
8 changes: 3 additions & 5 deletions src/Akavache.Core/BlobCache/InMemoryBlobCache.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Reactive.Disposables;

using Newtonsoft.Json;
using Newtonsoft.Json.Bson;

using Splat;

namespace Akavache;
Expand All @@ -22,7 +20,7 @@ public class InMemoryBlobCache : ISecureBlobCache, IObjectBlobCache, IEnableLogg
[SuppressMessage("Design", "CA2213: non-disposed field.", Justification = "Used for notification of dispose.")]
private readonly AsyncSubject<Unit> _shutdown = new();
private readonly IDisposable? _inner;
private readonly Dictionary<string, CacheEntry> _cache = new();
private readonly Dictionary<string, CacheEntry> _cache = [];
private readonly JsonDateTimeContractResolver _jsonDateTimeContractResolver = new(); // This will make us use ticks instead of json ticks for DateTime.
private bool _disposed;
private DateTimeKind? _dateTimeKind;
Expand Down Expand Up @@ -135,7 +133,7 @@ public static InMemoryBlobCache OverrideGlobals(IScheduler? scheduler = null, pa
/// <param name="initialContents">The default inner contents to use.</param>
/// <param name="scheduler">The default scheduler to use.</param>
/// <returns>A generated cache.</returns>
public static InMemoryBlobCache OverrideGlobals(IDictionary<string, byte[]> initialContents, IScheduler? scheduler = null) => OverrideGlobals(scheduler, initialContents.ToArray());
public static InMemoryBlobCache OverrideGlobals(IDictionary<string, byte[]> initialContents, IScheduler? scheduler = null) => OverrideGlobals(scheduler, [.. initialContents]);

/// <summary>
/// Overrides the global registrations with specified values.
Expand Down
7 changes: 2 additions & 5 deletions src/Akavache.Core/BlobCache/ObjectWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand All @@ -11,10 +11,7 @@ public ObjectWrapper()
{
}

public ObjectWrapper(T value)
{
Value = value;
}
public ObjectWrapper(T value) => Value = value;

public T? Value { get; set; }
}
2 changes: 1 addition & 1 deletion src/Akavache.Core/BulkOperationsMixin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/DataProtectionScope.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/DependencyResolverMixin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/ExceptionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/HttpMixinExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/IAkavacheHttpClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/IAkavacheHttpMixin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/IWantsToRegisterStuff.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion src/Akavache.Core/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
24 changes: 9 additions & 15 deletions src/Akavache.Core/Json/JsonDateTimeContractResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand All @@ -11,7 +11,12 @@ namespace Akavache;
/// Resolver which will handle DateTime and DateTimeOffset with our own internal resolver.
/// It will also be able to use, if set, a external provider that a user has set.
/// </summary>
internal class JsonDateTimeContractResolver : DefaultContractResolver
/// <remarks>
/// Initializes a new instance of the <see cref="JsonDateTimeContractResolver"/> class.
/// </remarks>
/// <param name="contractResolver">A inherited contract resolver.</param>
/// <param name="forceDateTimeKindOverride">If we should override the <see cref="DateTimeKind"/>.</param>
internal class JsonDateTimeContractResolver(IContractResolver? contractResolver, DateTimeKind? forceDateTimeKindOverride) : DefaultContractResolver
{
/// <summary>
/// Initializes a new instance of the <see cref="JsonDateTimeContractResolver"/> class.
Expand All @@ -21,20 +26,9 @@ public JsonDateTimeContractResolver()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="JsonDateTimeContractResolver"/> class.
/// </summary>
/// <param name="contractResolver">A inherited contract resolver.</param>
/// <param name="forceDateTimeKindOverride">If we should override the <see cref="DateTimeKind"/>.</param>
public JsonDateTimeContractResolver(IContractResolver? contractResolver, DateTimeKind? forceDateTimeKindOverride)
{
ExistingContractResolver = contractResolver;
ForceDateTimeKindOverride = forceDateTimeKindOverride;
}

public IContractResolver? ExistingContractResolver { get; set; }
public IContractResolver? ExistingContractResolver { get; set; } = contractResolver;

public DateTimeKind? ForceDateTimeKindOverride { get; set; }
public DateTimeKind? ForceDateTimeKindOverride { get; set; } = forceDateTimeKindOverride;

/// <inheritdoc />
public override JsonContract ResolveContract(Type type)
Expand Down
14 changes: 4 additions & 10 deletions src/Akavache.Core/Json/JsonDateTimeOffsetTickConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -33,17 +33,11 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

public override bool CanConvert(Type objectType) => objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?);

internal class DateTimeOffsetData
internal class DateTimeOffsetData(DateTimeOffset offset)
{
public DateTimeOffsetData(DateTimeOffset offset)
{
Ticks = offset.Ticks;
OffsetTicks = offset.Offset.Ticks;
}

public long Ticks { get; set; }
public long Ticks { get; set; } = offset.Ticks;

public long OffsetTicks { get; set; }
public long OffsetTicks { get; set; } = offset.Offset.Ticks;

public static explicit operator DateTimeOffset(DateTimeOffsetData value) // explicit byte to digit conversion operator
=>
Expand Down
Loading