diff --git a/src/Akavache.Core/Akavache.Core.csproj b/src/Akavache.Core/Akavache.Core.csproj index 52106e5fb..538f2aceb 100644 --- a/src/Akavache.Core/Akavache.Core.csproj +++ b/src/Akavache.Core/Akavache.Core.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid12.0;MonoAndroid12.1;MonoAndroid13.0;tizen40;net6.0;net6.0-android;net6.0-ios;net6.0-tvos;net6.0-macos;net6.0-maccatalyst;net7.0;net7.0-android;net7.0-ios;net7.0-tvos;net7.0-macos;net7.0-maccatalyst $(TargetFrameworks);net462;net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0 @@ -14,6 +14,7 @@ + @@ -30,10 +31,6 @@ - - - - diff --git a/src/Akavache.Core/Platforms/shared/DefaultAkavacheHttpClientFactory.cs b/src/Akavache.Core/Platforms/shared/DefaultAkavacheHttpClientFactory.cs index e9e9b3ee1..ba9506b8f 100644 --- a/src/Akavache.Core/Platforms/shared/DefaultAkavacheHttpClientFactory.cs +++ b/src/Akavache.Core/Platforms/shared/DefaultAkavacheHttpClientFactory.cs @@ -12,7 +12,7 @@ namespace Akavache; /// public class DefaultAkavacheHttpClientFactory : IAkavacheHttpClientFactory { - private static ConcurrentDictionary _instances = new(); + private static readonly ConcurrentDictionary _instances = new(); /// public HttpClient CreateClient(string name) => _instances.GetOrAdd(name, _ => new HttpClient()); diff --git a/src/Akavache.Core/Platforms/shared/EncryptionProvider.cs b/src/Akavache.Core/Platforms/shared/EncryptionProvider.cs index 2ac97c126..17ae7824a 100644 --- a/src/Akavache.Core/Platforms/shared/EncryptionProvider.cs +++ b/src/Akavache.Core/Platforms/shared/EncryptionProvider.cs @@ -3,12 +3,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -#if NET_461 -using RxCrypt = System.Security.Cryptography; -#else -using RxCrypt = Akavache; -#endif - namespace Akavache { /// diff --git a/src/Akavache.Core/Platforms/shared/Registrations.cs b/src/Akavache.Core/Platforms/shared/Registrations.cs index d45c81a92..f56cf09db 100644 --- a/src/Akavache.Core/Platforms/shared/Registrations.cs +++ b/src/Akavache.Core/Platforms/shared/Registrations.cs @@ -11,6 +11,9 @@ #if ANDROID using Android.App; +#if ANDROID33_0_OR_GREATER +using System.Runtime.Versioning; +#endif #endif namespace Akavache.Core @@ -22,6 +25,9 @@ namespace Akavache.Core public class Registrations : IWantsToRegisterStuff { /// +#if ANDROID && ANDROID33_0_OR_GREATER + [ObsoletedOSPlatform("android33.0")] +#endif public void Register(IMutableDependencyResolver resolver, IReadonlyDependencyResolver readonlyDependencyResolver) { if (resolver is null) diff --git a/src/Akavache.Mobile/Akavache.Mobile.csproj b/src/Akavache.Mobile/Akavache.Mobile.csproj index f3c7f5077..8485467b3 100644 --- a/src/Akavache.Mobile/Akavache.Mobile.csproj +++ b/src/Akavache.Mobile/Akavache.Mobile.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Akavache.Tests/API/ApiApprovalTests.AkavacheCore.net48.approved.txt b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheCore.net48.approved.txt new file mode 100644 index 000000000..fbd0915c9 --- /dev/null +++ b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheCore.net48.approved.txt @@ -0,0 +1,284 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/reactiveui/akavache")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Akavache")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Akavache.Drawing")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Akavache.Mobile")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Akavache.Sqlite3")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Akavache.Tests")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName=".NET Framework 4.6.2")] +namespace Akavache +{ + public class AkavacheHttpMixin : Akavache.IAkavacheHttpMixin + { + public AkavacheHttpMixin() { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + } + public static class BlobCache + { + public static string ApplicationName { get; set; } + public static System.DateTimeKind? ForcedDateTimeKind { get; set; } + public static Akavache.ISecureBlobCache InMemory { get; set; } + public static Akavache.IBlobCache LocalMachine { get; set; } + public static Akavache.ISecureBlobCache Secure { get; set; } + public static System.Reactive.Concurrency.IScheduler TaskpoolScheduler { get; set; } + public static Akavache.IBlobCache UserAccount { get; set; } + public static void EnsureInitialized() { } + public static System.Threading.Tasks.Task Shutdown() { } + } + public static class BulkOperationsMixin + { + public static System.IObservable> Get(this Akavache.IBlobCache blobCache, System.Collections.Generic.IEnumerable keys) { } + public static System.IObservable> GetCreatedAt(this Akavache.IBlobCache blobCache, System.Collections.Generic.IEnumerable keys) { } + public static System.IObservable> GetObjects(this Akavache.IBlobCache blobCache, System.Collections.Generic.IEnumerable keys) { } + public static System.IObservable Insert(this Akavache.IBlobCache blobCache, System.Collections.Generic.IDictionary keyValuePairs, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable InsertObjects(this Akavache.IBlobCache blobCache, System.Collections.Generic.IDictionary keyValuePairs, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable Invalidate(this Akavache.IBlobCache blobCache, System.Collections.Generic.IEnumerable keys) { } + public static System.IObservable InvalidateObjects(this Akavache.IBlobCache blobCache, System.Collections.Generic.IEnumerable keys) { } + } + public class CacheEntry + { + public CacheEntry(string? typeName, byte[] value, System.DateTimeOffset createdAt, System.DateTimeOffset? expiresAt) { } + public System.DateTimeOffset CreatedAt { get; set; } + public System.DateTimeOffset? ExpiresAt { get; set; } + public string? TypeName { get; set; } + public byte[] Value { get; set; } + } + public enum DataProtectionScope + { + CurrentUser = 0, + } + public class DefaultAkavacheHttpClientFactory : Akavache.IAkavacheHttpClientFactory + { + public DefaultAkavacheHttpClientFactory() { } + public System.Net.Http.HttpClient CreateClient(string name) { } + } + public static class DependencyResolverMixin + { + public static void InitializeAkavache(this Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver readonlyDependencyResolver) { } + } + public class EncryptionProvider : Akavache.IEncryptionProvider + { + public EncryptionProvider() { } + public System.IObservable DecryptBlock(byte[] block) { } + public System.IObservable EncryptBlock(byte[] block) { } + } + public static class HttpMixinExtensions + { + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default) { } + } + public interface IAkavacheHttpClientFactory + { + System.Net.Http.HttpClient CreateClient(string name); + } + public interface IAkavacheHttpMixin + { + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, string url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable DownloadUrl(Akavache.IBlobCache blobCache, System.Net.Http.HttpMethod method, string key, System.Uri url, System.Collections.Generic.IDictionary? headers = null, bool fetchAlways = false, System.DateTimeOffset? absoluteExpiration = default); + } + public interface IBlobCache : System.IDisposable + { + System.DateTimeKind? ForcedDateTimeKind { get; set; } + System.Reactive.Concurrency.IScheduler Scheduler { get; } + System.IObservable Shutdown { get; } + System.IObservable Flush(); + System.IObservable Get(string key); + System.IObservable> GetAllKeys(); + System.IObservable GetCreatedAt(string key); + System.IObservable Insert(string key, byte[] data, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable Invalidate(string key); + System.IObservable InvalidateAll(); + System.IObservable Vacuum(); + } + public interface IBulkBlobCache : Akavache.IBlobCache, System.IDisposable + { + System.IObservable> Get(System.Collections.Generic.IEnumerable keys); + System.IObservable> GetCreatedAt(System.Collections.Generic.IEnumerable keys); + System.IObservable Insert(System.Collections.Generic.IDictionary keyValuePairs, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable Invalidate(System.Collections.Generic.IEnumerable keys); + } + public interface IEncryptionProvider + { + System.IObservable DecryptBlock(byte[] block); + System.IObservable EncryptBlock(byte[] block); + } + public interface IFilesystemProvider + { + System.IObservable CreateRecursive(string path); + System.IObservable Delete(string path); + string? GetDefaultLocalMachineCacheDirectory(); + string? GetDefaultRoamingCacheDirectory(); + string? GetDefaultSecretCacheDirectory(); + System.IObservable OpenFileForReadAsync(string path, System.Reactive.Concurrency.IScheduler scheduler); + System.IObservable OpenFileForWriteAsync(string path, System.Reactive.Concurrency.IScheduler scheduler); + } + public interface IKeyedOperationQueue + { + System.IObservable EnqueueObservableOperation(string key, System.Func> asyncCalculationFunc); + System.IObservable EnqueueOperation(string key, System.Action action); + System.IObservable EnqueueOperation(string key, System.Func calculationFunc); + System.IObservable ShutdownQueue(); + } + public interface IObjectBlobCache : Akavache.IBlobCache, System.IDisposable + { + System.IObservable> GetAllObjects(); + System.IObservable GetObject(string key); + System.IObservable GetObjectCreatedAt(string key); + System.IObservable InsertObject(string key, T value, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable InvalidateAllObjects(); + System.IObservable InvalidateObject(string key); + } + public interface IObjectBulkBlobCache : Akavache.IBlobCache, Akavache.IBulkBlobCache, Akavache.IObjectBlobCache, System.IDisposable + { + System.IObservable> GetObjects(System.Collections.Generic.IEnumerable keys); + System.IObservable InsertObjects(System.Collections.Generic.IDictionary keyValuePairs, System.DateTimeOffset? absoluteExpiration = default); + System.IObservable InvalidateObjects(System.Collections.Generic.IEnumerable keys); + } + public interface ISecureBlobCache : Akavache.IBlobCache, System.IDisposable { } + public class InMemoryBlobCache : Akavache.IBlobCache, Akavache.IObjectBlobCache, Akavache.ISecureBlobCache, Splat.IEnableLogger, System.IDisposable + { + public InMemoryBlobCache() { } + public InMemoryBlobCache(System.Collections.Generic.IEnumerable> initialContents) { } + public InMemoryBlobCache(System.Reactive.Concurrency.IScheduler scheduler) { } + public InMemoryBlobCache(System.Reactive.Concurrency.IScheduler? scheduler, System.Collections.Generic.IEnumerable>? initialContents) { } + public System.DateTimeKind? ForcedDateTimeKind { get; set; } + public System.Reactive.Concurrency.IScheduler Scheduler { get; set; } + public System.IObservable Shutdown { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + public System.IObservable Flush() { } + public System.IObservable Get(string key) { } + public System.IObservable> GetAllKeys() { } + public System.IObservable> GetAllObjects() { } + public System.IObservable GetCreatedAt(string key) { } + public System.IObservable GetObject(string key) { } + public System.IObservable GetObjectCreatedAt(string key) { } + public System.IObservable Insert(string key, byte[] data, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable InsertObject(string key, T value, System.DateTimeOffset? absoluteExpiration = default) { } + public System.IObservable Invalidate(string key) { } + public System.IObservable InvalidateAll() { } + public System.IObservable InvalidateAllObjects() { } + public System.IObservable InvalidateObject(string key) { } + public System.IObservable Vacuum() { } + public static Akavache.InMemoryBlobCache OverrideGlobals(System.Collections.Generic.IDictionary initialContents, System.Reactive.Concurrency.IScheduler? scheduler = null) { } + public static Akavache.InMemoryBlobCache OverrideGlobals(System.Collections.Generic.IDictionary initialContents, System.Reactive.Concurrency.IScheduler? scheduler = null) { } + public static Akavache.InMemoryBlobCache OverrideGlobals(System.Reactive.Concurrency.IScheduler? scheduler = null, params System.Collections.Generic.KeyValuePair[] initialContents) { } + } + public static class JsonSerializationMixin + { + public static System.IObservable> GetAllObjects(this Akavache.IBlobCache blobCache) { } + public static System.IObservable GetAndFetchLatest(this Akavache.IBlobCache blobCache, string key, System.Func> fetchFunc, System.Func? fetchPredicate = null, System.DateTimeOffset? absoluteExpiration = default, bool shouldInvalidateOnError = false, System.Func? cacheValidationPredicate = null) { } + public static System.IObservable GetAndFetchLatest(this Akavache.IBlobCache blobCache, string key, System.Func> fetchFunc, System.Func? fetchPredicate = null, System.DateTimeOffset? absoluteExpiration = default, bool shouldInvalidateOnError = false, System.Func? cacheValidationPredicate = null) { } + public static System.IObservable GetObject(this Akavache.IBlobCache blobCache, string key) { } + public static System.IObservable GetObjectCreatedAt(this Akavache.IBlobCache blobCache, string key) { } + public static System.IObservable GetOrCreateObject(this Akavache.IBlobCache blobCache, string key, System.Func fetchFunc, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable GetOrFetchObject(this Akavache.IBlobCache blobCache, string key, System.Func> fetchFunc, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable GetOrFetchObject(this Akavache.IBlobCache blobCache, string key, System.Func> fetchFunc, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable InsertAllObjects(this Akavache.IBlobCache blobCache, System.Collections.Generic.IDictionary keyValuePairs, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable InsertObject(this Akavache.IBlobCache blobCache, string key, T value, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable InvalidateAllObjects(this Akavache.IBlobCache blobCache) { } + public static System.IObservable InvalidateObject(this Akavache.IBlobCache blobCache, string key) { } + } + public class KeyedOperationQueue : Akavache.IKeyedOperationQueue, Splat.IEnableLogger, System.IDisposable + { + public KeyedOperationQueue(System.Reactive.Concurrency.IScheduler? scheduler = null) { } + public void Dispose() { } + protected virtual void Dispose(bool disposing) { } + public System.IObservable EnqueueObservableOperation(string key, System.Func> asyncCalculationFunc) { } + public System.IObservable EnqueueOperation(string key, System.Action action) { } + public System.IObservable EnqueueOperation(string key, System.Func calculationFunc) { } + public System.IObservable ShutdownQueue() { } + } + public class LoginInfo + { + public LoginInfo(string username, string password) { } + public string Password { get; } + public string UserName { get; } + } + public static class LoginMixin + { + public static System.IObservable EraseLogin(this Akavache.ISecureBlobCache blobCache, string host = "default") { } + public static System.IObservable GetLoginAsync(this Akavache.ISecureBlobCache blobCache, string host = "default") { } + public static System.IObservable SaveLogin(this Akavache.ISecureBlobCache blobCache, string user, string password, string host = "default", System.DateTimeOffset? absoluteExpiration = default) { } + } + public static class ProtectedData + { + public static byte[] Protect(byte[] originalData, byte[]? entropy, Akavache.DataProtectionScope scope = 0) { } + public static byte[] Unprotect(byte[] originalData, byte[]? entropy, Akavache.DataProtectionScope scope = 0) { } + } + public static class RelativeTimeMixin + { + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, string url, System.TimeSpan expiration, System.Collections.Generic.Dictionary? headers = null, bool fetchAlways = false) { } + public static System.IObservable DownloadUrl(this Akavache.IBlobCache blobCache, System.Uri url, System.TimeSpan expiration, System.Collections.Generic.Dictionary? headers = null, bool fetchAlways = false) { } + public static System.IObservable Insert(this Akavache.IBlobCache blobCache, string key, byte[] data, System.TimeSpan expiration) { } + public static System.IObservable InsertObject(this Akavache.IBlobCache blobCache, string key, T value, System.TimeSpan expiration) { } + public static System.IObservable SaveLogin(this Akavache.ISecureBlobCache blobCache, string user, string password, string host, System.TimeSpan expiration) { } + } + public class SimpleFilesystemProvider : Akavache.IFilesystemProvider + { + public SimpleFilesystemProvider() { } + public System.IObservable CreateRecursive(string path) { } + public System.IObservable Delete(string path) { } + public string GetDefaultLocalMachineCacheDirectory() { } + public string GetDefaultRoamingCacheDirectory() { } + public string GetDefaultSecretCacheDirectory() { } + public System.IObservable OpenFileForReadAsync(string path, System.Reactive.Concurrency.IScheduler scheduler) { } + public System.IObservable OpenFileForWriteAsync(string path, System.Reactive.Concurrency.IScheduler scheduler) { } + protected static string GetAssemblyDirectoryName() { } + } +} +namespace Akavache.Core +{ + public class Registrations + { + public Registrations() { } + public void Register(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver readonlyDependencyResolver) { } + } +} +namespace Akavache.Internal +{ + [System.Flags] + public enum FileAccess + { + Read = 1, + Write = 2, + ReadWrite = 3, + } + public enum FileMode + { + CreateNew = 1, + Create = 2, + Open = 3, + OpenOrCreate = 4, + Truncate = 5, + Append = 6, + } + [System.Flags] + public enum FileShare + { + None = 0, + Read = 1, + Write = 2, + ReadWrite = 3, + Delete = 4, + Inheritable = 16, + } +} \ No newline at end of file diff --git a/src/Akavache.Tests/API/ApiApprovalTests.AkavacheDrawing.net48.approved.txt b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheDrawing.net48.approved.txt new file mode 100644 index 000000000..4592f6631 --- /dev/null +++ b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheDrawing.net48.approved.txt @@ -0,0 +1,22 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/reactiveui/akavache")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName=".NET Framework 4.6.2")] +namespace Akavache +{ + public static class BitmapImageMixin + { + public static System.IObservable LoadImage(this Akavache.IBlobCache blobCache, string key, float? desiredWidth = default, float? desiredHeight = default) { } + public static System.IObservable LoadImageFromUrl(this Akavache.IBlobCache blobCache, string url, bool fetchAlways = false, float? desiredWidth = default, float? desiredHeight = default, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable LoadImageFromUrl(this Akavache.IBlobCache blobCache, System.Uri url, bool fetchAlways = false, float? desiredWidth = default, float? desiredHeight = default, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable LoadImageFromUrl(this Akavache.IBlobCache blobCache, string key, string url, bool fetchAlways = false, float? desiredWidth = default, float? desiredHeight = default, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable LoadImageFromUrl(this Akavache.IBlobCache blobCache, string key, System.Uri url, bool fetchAlways = false, float? desiredWidth = default, float? desiredHeight = default, System.DateTimeOffset? absoluteExpiration = default) { } + public static System.IObservable ThrowOnBadImageBuffer(byte[] compressedImage) { } + } +} +namespace Akavache.Drawing +{ + public class Registrations + { + public Registrations() { } + public void Register(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver readonlyDependencyResolver) { } + } +} \ No newline at end of file diff --git a/src/Akavache.Tests/API/ApiApprovalTests.AkavacheProject.net48.approved.txt b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheProject.net48.approved.txt new file mode 100644 index 000000000..cf779bcb6 --- /dev/null +++ b/src/Akavache.Tests/API/ApiApprovalTests.AkavacheProject.net48.approved.txt @@ -0,0 +1,19 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/reactiveui/akavache")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName=".NET Framework 4.6.2")] +namespace Akavache +{ + public class Registrations + { + public Registrations() { } + public void Register(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver readonlyDependencyResolver) { } + public static void Start(string applicationName) { } + } +} +namespace Akavache.Sqlite3 +{ + public static class LinkerPreserve { } + public class SQLitePersistentBlobCache : Akavache.Sqlite3.SqlRawPersistentBlobCache + { + public SQLitePersistentBlobCache(string databaseFile, System.Reactive.Concurrency.IScheduler? scheduler = null) { } + } +} \ No newline at end of file diff --git a/src/Akavache.Tests/Akavache.Tests.csproj b/src/Akavache.Tests/Akavache.Tests.csproj index 7575eae88..befcab919 100644 --- a/src/Akavache.Tests/Akavache.Tests.csproj +++ b/src/Akavache.Tests/Akavache.Tests.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -7,19 +7,23 @@ disable + + + + - + - + - - + + all diff --git a/src/Akavache.Tests/BasicEncryptionTests.cs b/src/Akavache.Tests/BasicEncryptionTests.cs index c1c482df7..1a955da4c 100644 --- a/src/Akavache.Tests/BasicEncryptionTests.cs +++ b/src/Akavache.Tests/BasicEncryptionTests.cs @@ -21,6 +21,7 @@ public class BasicEncryptionTests [SkippableFact] public async Task ShouldEncrypt() { + // TODO: This test is failing on .NET 6.0. Investigate. Skip.IfNot(GetType().Assembly.GetTargetFrameworkName().StartsWith("net4")); var provider = new EncryptionProvider(); @@ -51,4 +52,4 @@ public async Task ShouldDecrypt() } private static async Task AsArray(IObservable source) => await source.FirstAsync(); -} \ No newline at end of file +} diff --git a/src/Akavache.Tests/TestBases/BlobCacheExtensionsTestBase.cs b/src/Akavache.Tests/TestBases/BlobCacheExtensionsTestBase.cs index d7c58d4eb..a5fdec7ca 100644 --- a/src/Akavache.Tests/TestBases/BlobCacheExtensionsTestBase.cs +++ b/src/Akavache.Tests/TestBases/BlobCacheExtensionsTestBase.cs @@ -10,7 +10,7 @@ using Microsoft.Reactive.Testing; using ReactiveUI.Testing; - +using Splat; using Xunit; namespace Akavache.Tests; @@ -31,7 +31,7 @@ public async Task DownloadUrlTest() using (var fixture = CreateBlobCache(path)) { var bytes = await fixture.DownloadUrl("http://httpbin.org/html").FirstAsync(); - Assert.True(bytes.Length > 0); + bytes.Length.Should().BeGreaterThan(0); } } @@ -46,7 +46,7 @@ public async Task DownloadUriTest() using (var fixture = CreateBlobCache(path)) { var bytes = await fixture.DownloadUrl(new Uri("http://httpbin.org/html")).FirstAsync(); - Assert.True(bytes.Length > 0); + bytes.Length.Should().BeGreaterThan(0); } } @@ -63,7 +63,7 @@ public async Task DownloadUrlWithKeyTest() var key = Guid.NewGuid().ToString(); await fixture.DownloadUrl(key, "http://httpbin.org/html").FirstAsync(); var bytes = await fixture.Get(key); - Assert.True(bytes.Length > 0); + bytes.Length.Should().BeGreaterThan(0); } } @@ -78,9 +78,9 @@ public async Task DownloadUriWithKeyTest() using (var fixture = CreateBlobCache(path)) { var key = Guid.NewGuid().ToString(); - await fixture.DownloadUrl(key, new Uri("http://httpbin.org/html")).FirstAsync(); + await fixture.DownloadUrl(key, new Uri("https://httpbin.org/html")).FirstAsync(); var bytes = await fixture.Get(key); - Assert.True(bytes.Length > 0); + bytes.Length.Should().BeGreaterThan(0); } } @@ -170,9 +170,9 @@ public async Task ArraysShouldBeRoundtrippable() } } - Assert.Equal(input.First().Blog, result.First().Blog); - Assert.Equal(input.First().Bio, result.First().Bio); - Assert.Equal(input.First().Name, result.First().Name); + Assert.Equal(input[0].Blog, result[0].Blog); + Assert.Equal(input[0].Bio, result[0].Bio); + Assert.Equal(input[0].Name, result[0].Name); Assert.Equal(input.Last().Blog, result.Last().Blog); Assert.Equal(input.Last().Bio, result.Last().Bio); Assert.Equal(input.Last().Name, result.Last().Name); @@ -237,8 +237,8 @@ public async Task ArraysShouldBeRoundtrippableUsingObjectFactory() } } - Assert.Equal(input.First().Age, result.First().Age); - Assert.Equal(input.First().Name, result.First().Name); + Assert.Equal(input[0].Age, result[0].Age); + Assert.Equal(input[0].Name, result[0].Name); Assert.Equal(input.Last().Age, result.Last().Age); Assert.Equal(input.Last().Name, result.Last().Name); } @@ -247,9 +247,12 @@ public async Task ArraysShouldBeRoundtrippableUsingObjectFactory() /// Make sure that the fetch functions are called only once for the get or fetch object methods. /// /// A task to monitor the progress. - [Fact(Skip = "Failing at the moment. Fix later.")] + [SkippableFact] public async Task FetchFunctionShouldBeCalledOnceForGetOrFetchObject() { + // TODO: This test is failing on .NET 6.0. Investigate. + Skip.IfNot(GetType().Assembly.GetTargetFrameworkName().StartsWith("net4")); + var fetchCount = 0; var fetcher = new Func>>(() => { @@ -292,10 +295,12 @@ public async Task FetchFunctionShouldBeCalledOnceForGetOrFetchObject() /// /// Makes sure the fetch function debounces current requests. /// - [Fact(Skip = "TestScheduler tests aren't gonna work with new SQLite")] + [SkippableFact] public void FetchFunctionShouldDebounceConcurrentRequests() => new TestScheduler().With(sched => { + // TODO: TestScheduler tests aren't gonna work with new SQLite. + Skip.IfNot(GetType().Assembly.GetTargetFrameworkName().StartsWith("net4")); using (Utility.WithEmptyDirectory(out var path)) { var callCount = 0; @@ -424,10 +429,12 @@ public async Task FetchFunctionShouldPropagateObservedExceptionAsObservableExcep /// /// Make sure that the GetOrFetch function respects expirations. /// - [Fact(Skip = "TestScheduler tests aren't gonna work with new SQLite")] + [SkippableFact] public void GetOrFetchShouldRespectExpiration() => new TestScheduler().With(sched => { + // TODO: TestScheduler tests aren't gonna work with new SQLite. + Skip.IfNot(GetType().Assembly.GetTargetFrameworkName().StartsWith("net4")); using (Utility.WithEmptyDirectory(out var path)) { var fixture = CreateBlobCache(path); @@ -510,7 +517,7 @@ public async Task GetAndFetchLatestCallsFetchPredicate() { var fetchPredicateCalled = false; - bool FetchPredicate(DateTimeOffset d) + bool FetchPredicate(DateTimeOffset _) { fetchPredicateCalled = true; @@ -573,7 +580,7 @@ public async Task GetAndFetchLatestValidatesItemsToBeCached() // GetAndFetchLatest skips cache invalidation/storage due to cache validation predicate. await fixture.InsertObject(key, items); - await fixture.GetAndFetchLatest(key, fetcher, cacheValidationPredicate: i => i is not null && i.Count > 0).LastAsync(); + await fixture.GetAndFetchLatest(key, fetcher, cacheValidationPredicate: i => i?.Count > 0).LastAsync(); var result = await fixture.GetObject>(key).FirstAsync(); diff --git a/src/Akavache.Tests/TestBases/BlobCacheInterfaceTestBase.cs b/src/Akavache.Tests/TestBases/BlobCacheInterfaceTestBase.cs index 019aa496a..264ea027b 100644 --- a/src/Akavache.Tests/TestBases/BlobCacheInterfaceTestBase.cs +++ b/src/Akavache.Tests/TestBases/BlobCacheInterfaceTestBase.cs @@ -8,7 +8,7 @@ using Microsoft.Reactive.Testing; using ReactiveUI.Testing; - +using Splat; using Xunit; namespace Akavache.Tests; @@ -138,9 +138,11 @@ public async Task InsertingAnItemTwiceShouldAlwaysGetTheNewOne() /// /// Checks to make sure that the cache respects expiration dates. /// - [Fact(Skip = "TestScheduler tests aren't gonna work with new SQLite")] + [SkippableFact] public void CacheShouldRespectExpiration() { + // TODO: TestScheduler tests aren't gonna work with new SQLite. + Skip.IfNot(GetType().Assembly.GetTargetFrameworkName().StartsWith("net4")); using (Utility.WithEmptyDirectory(out var path)) { new TestScheduler().With(sched => @@ -353,4 +355,4 @@ public async Task VacuumPurgeEntriesThatAreExpired() /// The path to the blob cache. /// The blob cache for testing. protected abstract IBlobCache CreateBlobCache(string path); -} \ No newline at end of file +} diff --git a/src/Directory.build.props b/src/Directory.build.props index d99c880a9..a11392109 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -25,6 +25,7 @@ latest enable enable + IDE1006;SA1313;