diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 493e9be..ca2fba5 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -3,53 +3,60 @@ name: .NET -on: - push: - tags: - - 'v**' +on: + push: + tags: + - "v**" jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '7.x' - source-url: https://nuget.pkg.github.com/theeightbot/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - - name: Semver Parse - id: version - uses: release-kit/semver@v1.0.10 - - - name: Build Tycho.JsonSerializer - run: dotnet build Tycho.JsonSerializer/Tycho.JsonSerializer.csproj - - name: Create the package - run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Tycho.JsonSerializer/Tycho.JsonSerializer.csproj - - name: Publish the package to GPR - run: dotnet nuget push Tycho.JsonSerializer/bin/Release/*.nupkg - - - name: Build Tycho.JsonSerializer.NewtonsoftJson - run: dotnet build Tycho.JsonSerializer.NewtonsoftJson/Tycho.JsonSerializer.NewtonsoftJson.csproj - - name: Create the package - run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Tycho.JsonSerializer.NewtonsoftJson/Tycho.JsonSerializer.NewtonsoftJson.csproj - - name: Publish the package to GPR - run: dotnet nuget push Tycho.JsonSerializer.NewtonsoftJson/bin/Release/*.nupkg - - - name: Build Tycho.JsonSerializer.SystemTextJson - run: dotnet build Tycho.JsonSerializer.SystemTextJson/Tycho.JsonSerializer.SystemTextJson.csproj - - name: Create the package - run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Tycho.JsonSerializer.SystemTextJson/Tycho.JsonSerializer.SystemTextJson.csproj - - name: Publish the package to GPR - run: dotnet nuget push Tycho.JsonSerializer.SystemTextJson/bin/Release/*.nupkg - - - name: Build Tycho - run: dotnet build Tycho/Tycho.csproj - - name: Create the package - run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Tycho/Tycho.csproj - - name: Publish the package to GPR - run: dotnet nuget push Tycho/bin/Release/*.nupkg \ No newline at end of file + build: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: "8.x" + source-url: https://nuget.pkg.github.com/theeightbot/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Semver Parse + id: version + uses: release-kit/semver@v1.0.10 + + - name: Build TychoDB.JsonSerializer + run: dotnet build TychoDB.JsonSerializer/TychoDB.JsonSerializer.csproj + - name: Create the package + run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} TychoDB.JsonSerializer/TychoDB.JsonSerializer.csproj + - name: Publish the package to GPR + run: dotnet nuget push TychoDB.JsonSerializer/bin/Release/*.nupkg + - name: Publish the package to NuGet + run: dotnet nuget push TychoDB.JsonSerializer/bin/Release/*.nupkg --api-key "${{ secrets.EIGHTBOT_NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json + + - name: Build TychoDB.JsonSerializer.NewtonsoftJson + run: dotnet build TychoDB.JsonSerializer.NewtonsoftJson/TychoDB.JsonSerializer.NewtonsoftJson.csproj + - name: Create the package + run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} TychoDB.JsonSerializer.NewtonsoftJson/TychoDB.JsonSerializer.NewtonsoftJson.csproj + - name: Publish the package to GPR + run: dotnet nuget push TychoDB.JsonSerializer.NewtonsoftJson/bin/Release/*.nupkg + - name: Publish the package to NuGet + run: dotnet nuget push TychoDB.JsonSerializer.NewtonsoftJson/bin/Release/*.nupkg --api-key "${{ secrets.EIGHTBOT_NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json + + - name: Build TychoDB.JsonSerializer.SystemTextJson + run: dotnet build TychoDB.JsonSerializer.SystemTextJson/TychoDB.JsonSerializer.SystemTextJson.csproj + - name: Create the package + run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} TychoDB.JsonSerializer.SystemTextJson/TychoDB.JsonSerializer.SystemTextJson.csproj + - name: Publish the package to GPR + run: dotnet nuget push TychoDB.JsonSerializer.SystemTextJson/bin/Release/*.nupkg + - name: Publish the package to NuGet + run: dotnet nuget push TychoDB.JsonSerializer.SystemTextJson/bin/Release/*.nupkg --api-key "${{ secrets.EIGHTBOT_NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json + + - name: Build Tycho + run: dotnet build TychoDB/TychoDB.csproj + - name: Create the package + run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Tycho/TychoDB.csproj + - name: Publish the package to GPR + run: dotnet nuget push TychoDB/bin/Release/*.nupkg + - name: Publish the package to NuGet + run: dotnet nuget push TychoDB/bin/Release/*.nupkg --api-key "${{ secrets.EIGHTBOT_NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json diff --git a/Directory.build.props b/Directory.build.props index 7a431a8..fd1a63b 100644 --- a/Directory.build.props +++ b/Directory.build.props @@ -1,16 +1,41 @@ - - true - latest - $(NoWarn);CS1591 - - - - - - - - - - - + + true + latest + $(NoWarn);CS1591 + + + Eight-Bot, Inc. + 2023 Eight-Bot + icon.png + Eight-Bot, Inc. + https://eight.bot + https://github.com/TheEightBot/TychoDB + git + nosql;database;json + Tycho DB + Lightweight and highly opioninated NoSQL database written on top of SQLite + Lightweight and highly opioninated NoSQL database written on top of SQLite + logo.png + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tycho.Benchmarks/TestModels.cs b/Tycho.Benchmarks/TestModels.cs deleted file mode 100644 index 3fdfcd0..0000000 --- a/Tycho.Benchmarks/TestModels.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; -using SQLite; - -namespace Tycho.Benchmarks -{ - public class TestClassA - { - [PrimaryKey] - public string StringProperty { get; set; } - - public long LongProperty { get; set; } - - public long TimestampMillis { get; set; } - } - - public class TestClassB - { - public string StringProperty { get; set; } - - public double DoubleProperty { get; set; } - } - - public class TestClassC - { - [PrimaryKey] - public int IntProperty { get; set; } - - public double DoubleProperty { get; set; } - } - - public class TestClassD - { - [PrimaryKey] - public float FloatProperty { get; set; } - - public double DoubleProperty { get; set; } - - public TestClassC ValueC { get; set; } - } - - public class TestClassE - { - [PrimaryKey] - public Guid TestClassId { get; set; } - - public IEnumerable Values { get; set; } - } - - public class TestClassF - { - public Guid TestClassId { get; set; } - - public TestClassD Value { get; set; } - } -} diff --git a/Tycho.Benchmarks/Tycho.Benchmarks.csproj b/Tycho.Benchmarks/Tycho.Benchmarks.csproj deleted file mode 100644 index 2556d06..0000000 --- a/Tycho.Benchmarks/Tycho.Benchmarks.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - Exe - net7.0 - Debug;Release;Encrypted - - - - - - 4 - - - obj\Release - - true - ENCRYPTED; - 4 - - - - - - - - - - - - - - - - - - - - - diff --git a/Tycho.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs b/Tycho.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs deleted file mode 100644 index 079b43c..0000000 --- a/Tycho.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace Tycho -{ - public class NewtonsoftJsonSerializer : IJsonSerializer - { - private readonly JsonSerializer _jsonSerializer; - - private readonly JsonSerializerSettings _jsonSerializerSettings; - - public string DateTimeSerializationFormat { get; } - - public NewtonsoftJsonSerializer( - JsonSerializer jsonSerializer = null, - JsonSerializerSettings jsonSerializerSettings = null, - string dateTimeSerializationFormat = "O") - { - DateTimeSerializationFormat = dateTimeSerializationFormat; - - _jsonSerializer = - jsonSerializer ?? - new JsonSerializer - { - DefaultValueHandling = DefaultValueHandling.Include, - NullValueHandling = NullValueHandling.Ignore, - DateFormatString = dateTimeSerializationFormat, - }; - - _jsonSerializerSettings = - jsonSerializerSettings ?? - new JsonSerializerSettings - { - DefaultValueHandling = DefaultValueHandling.Include, - NullValueHandling = NullValueHandling.Include, - DateFormatString = dateTimeSerializationFormat, - }; - } - - public ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken) - { - using var streamReader = new StreamReader(stream); - using var jsonTextReader = - new JsonTextReader(streamReader) - { - DateFormatString = DateTimeSerializationFormat, - }; - - return new ValueTask(_jsonSerializer.Deserialize(jsonTextReader)); - } - - public object Serialize(T obj) - { - return JsonConvert.SerializeObject(obj, _jsonSerializerSettings); - } - - public override string ToString() => nameof(NewtonsoftJsonSerializer); - } -} \ No newline at end of file diff --git a/Tycho.JsonSerializer.NewtonsoftJson/Tycho.JsonSerializer.NewtonsoftJson.csproj b/Tycho.JsonSerializer.NewtonsoftJson/Tycho.JsonSerializer.NewtonsoftJson.csproj deleted file mode 100644 index 28ef460..0000000 --- a/Tycho.JsonSerializer.NewtonsoftJson/Tycho.JsonSerializer.NewtonsoftJson.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - netstandard2.1;NET7.0 - Latest - Tycho.JsonSerializer.NewtonsoftJson - Eight-Bot, Inc. - 2023 Eight-Bot - icon.png - Eight-Bot, Inc. - https://github.com/TheEightBot/Tycho - nosql database json - Tycho DB - Newtonsoft JSON.NET Serializer - Lightweight and highly opioninated NoSQL database written on top of SQLite - Lightweight and highly opioninated NoSQL database written on top of SQLite - - - - - - - - - - - \ No newline at end of file diff --git a/Tycho.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs b/Tycho.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs deleted file mode 100644 index 13b44c6..0000000 --- a/Tycho.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Text.Json.Serialization.Metadata; -using System.Threading; -using System.Threading.Tasks; - -namespace Tycho -{ - public class SystemTextJsonSerializer : IJsonSerializer - { - private readonly JsonSerializerOptions _jsonSerializerOptions; - - private readonly Dictionary _jsonTypeSerializers; - - public string DateTimeSerializationFormat { get; } - - public SystemTextJsonSerializer( - JsonSerializerOptions jsonSerializerOptions = null, - Dictionary jsonTypeSerializers = null, - string dateTimeSerializationFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") - { - DateTimeSerializationFormat = dateTimeSerializationFormat; - - _jsonSerializerOptions = - jsonSerializerOptions ?? - new JsonSerializerOptions - { - IgnoreReadOnlyProperties = true, - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - }; - - _jsonTypeSerializers = - jsonTypeSerializers - ?? new Dictionary(); - } - - public ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken) - { - if (_jsonTypeSerializers.TryGetValue(typeof(T), out var jsonTypeSerializer) && jsonTypeSerializer is JsonTypeInfo jtst) - { - return JsonSerializer.DeserializeAsync(stream, jtst, cancellationToken); - } - - return JsonSerializer.DeserializeAsync(stream, _jsonSerializerOptions, cancellationToken); - } - - public object Serialize(T obj) - { - if (_jsonTypeSerializers.TryGetValue(typeof(T), out var jsonTypeSerializer) && jsonTypeSerializer is JsonTypeInfo jtst) - { - return JsonSerializer.SerializeToUtf8Bytes(obj, jtst); - } - - return JsonSerializer.SerializeToUtf8Bytes(obj, _jsonSerializerOptions); - } - - public override string ToString() => nameof(SystemTextJsonSerializer); - } -} diff --git a/Tycho.JsonSerializer.SystemTextJson/Tycho.JsonSerializer.SystemTextJson.csproj b/Tycho.JsonSerializer.SystemTextJson/Tycho.JsonSerializer.SystemTextJson.csproj deleted file mode 100644 index cff4c3f..0000000 --- a/Tycho.JsonSerializer.SystemTextJson/Tycho.JsonSerializer.SystemTextJson.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - netstandard2.1;NET7.0 - Latest - Tycho.JsonSerializer.SystemTextJson - Eight-Bot, Inc. - 2023 Eight-Bot - icon.png - Eight-Bot, Inc. - https://github.com/TheEightBot/Tycho - nosql database json - Tycho DB - System.Text.Json Serializer - Lightweight and highly opioninated NoSQL database written on top of SQLite - Lightweight and highly opioninated NoSQL database written on top of SQLite - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tycho.JsonSerializer/IJsonSerializer.cs b/Tycho.JsonSerializer/IJsonSerializer.cs deleted file mode 100644 index bcbe82f..0000000 --- a/Tycho.JsonSerializer/IJsonSerializer.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace Tycho -{ - public interface IJsonSerializer - { - string DateTimeSerializationFormat { get; } - - object Serialize(T obj); - - ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken); - } -} diff --git a/Tycho.JsonSerializer/Tycho.JsonSerializer.csproj b/Tycho.JsonSerializer/Tycho.JsonSerializer.csproj deleted file mode 100644 index 591bb1f..0000000 --- a/Tycho.JsonSerializer/Tycho.JsonSerializer.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netstandard2.1;NET7.0 - Latest - Tycho.JsonSerializer - Eight-Bot, Inc. - 2023 Eight-Bot - icon.png - Eight-Bot, Inc. - https://github.com/TheEightBot/Tycho - nosql database json - Tycho DB - Newtonsoft JSON.NET Serializer - Lightweight and highly opioninated NoSQL database written on top of SQLite - Lightweight and highly opioninated NoSQL database written on top of SQLite - - - - - - diff --git a/Tycho.UnitTests/FodyWeavers.xsd b/Tycho.UnitTests/FodyWeavers.xsd deleted file mode 100644 index 69dbe48..0000000 --- a/Tycho.UnitTests/FodyWeavers.xsd +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - Used to control if the On_PropertyName_Changed feature is enabled. - - - - - Used to control if the Dependent properties feature is enabled. - - - - - Used to control if the IsChanged property feature is enabled. - - - - - Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. - - - - - Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project. - - - - - Used to control if equality checks should use the Equals method resolved from the base class. - - - - - Used to control if equality checks should use the static Equals method resolved from the base class. - - - - - Used to turn off build warnings from this weaver. - - - - - Used to turn off build warnings about mismatched On_PropertyName_Changed methods. - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/Tycho.UnitTests/Tycho.UnitTests.csproj b/Tycho.UnitTests/Tycho.UnitTests.csproj deleted file mode 100644 index 27568cf..0000000 --- a/Tycho.UnitTests/Tycho.UnitTests.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - - net7.0 - - false - Debug;Release;Encrypted - - - - TRACE;DEBUG;NET;NET5_0;NETCOREAPP; - 4 - - - - 4 - - - obj\Release\net5.0 - - true - bin\Encrypted\net5.0 - TRACE;RELEASE;NET;NET5_0;NETCOREAPP;ENCRYPTED; - 4 - - 1701;1702 - true - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - - - diff --git a/Tycho/Tycho.csproj b/Tycho/Tycho.csproj deleted file mode 100644 index a17d56b..0000000 --- a/Tycho/Tycho.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - netstandard2.1;NET7.0 - Latest - Tycho - Eight-Bot, Inc. - 2023 Eight-Bot - icon.png - Eight-Bot, Inc. - https://github.com/TheEightBot/Tycho - nosql database json - Tycho DB - Lightweight and highly opioninated NoSQL database written on top of SQLite - Lightweight and highly opioninated NoSQL database written on top of SQLite - Encrypted;Debug;Release - - - - obj\Encrypted - true - bin\Encrypted - TRACE;RELEASE;ENCRYPTED;NETSTANDARD;NETSTANDARD2_1; - Latest - true - Tycho.Encrypted - - - - true - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tycho/TychoDbException.cs b/Tycho/TychoDbException.cs deleted file mode 100644 index 234a1a1..0000000 --- a/Tycho/TychoDbException.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Tycho; - -public class TychoDbException : Exception -{ - public TychoDbException() - { - } - - public TychoDbException(string message) - : base(message) - { - } - - public TychoDbException(string message, Exception innerException) - : base(message, innerException) - { - } - - protected TychoDbException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } -} \ No newline at end of file diff --git a/Tycho.Benchmarks/Benchmarks/Insertion.cs b/TychoDB.Benchmarks/Benchmarks/Insertion.cs similarity index 97% rename from Tycho.Benchmarks/Benchmarks/Insertion.cs rename to TychoDB.Benchmarks/Benchmarks/Insertion.cs index 61d528c..cb1e8f3 100644 --- a/Tycho.Benchmarks/Benchmarks/Insertion.cs +++ b/TychoDB.Benchmarks/Benchmarks/Insertion.cs @@ -7,10 +7,10 @@ using System.Threading; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; -using Microsoft.Diagnostics.Tracing.Parsers.ApplicationServer; using SQLite; +using TychoDB; -namespace Tycho.Benchmarks.Benchmarks; +namespace TychoDB.Benchmarks.Benchmarks; [MemoryDiagnoser] [SimpleJob(launchCount: 1, warmupCount: 1, invocationCount: 100)] @@ -358,12 +358,12 @@ public async Task InsertManyBulkSqliteAsync() await db.InsertAllAsync(list).ConfigureAwait(false); } - public TychoDb BuildDatabaseConnection() + public Tycho BuildDatabaseConnection() { #if ENCRYPTED - return new TychoDb(TempPath, JsonSerializer, "tycho_cache_enc.db", "Password", rebuildCache: true); + return new Tycho(TempPath, JsonSerializer, "tycho_cache_enc.db", "Password", rebuildCache: true); #else - return new TychoDb(TempPath, JsonSerializer, rebuildCache: true); + return new Tycho(TempPath, JsonSerializer, rebuildCache: true); #endif } } diff --git a/Tycho.Benchmarks/Program.cs b/TychoDB.Benchmarks/Program.cs similarity index 86% rename from Tycho.Benchmarks/Program.cs rename to TychoDB.Benchmarks/Program.cs index 8b6660c..4b8dbe2 100644 --- a/Tycho.Benchmarks/Program.cs +++ b/TychoDB.Benchmarks/Program.cs @@ -1,7 +1,7 @@ using System; using BenchmarkDotNet.Running; -namespace Tycho.Benchmarks; +namespace TychoDB.Benchmarks; public static class Program { @@ -9,4 +9,4 @@ public static void Main(string[] args) { var summary = BenchmarkRunner.Run(); } -} \ No newline at end of file +} diff --git a/TychoDB.Benchmarks/TestModels.cs b/TychoDB.Benchmarks/TestModels.cs new file mode 100644 index 0000000..30d63b2 --- /dev/null +++ b/TychoDB.Benchmarks/TestModels.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using SQLite; + +namespace TychoDB.Benchmarks; + +public class TestModels() +{ +} + +public class TestClassA +{ + [PrimaryKey] + public string StringProperty { get; set; } + + public long LongProperty { get; set; } + + public long TimestampMillis { get; set; } +} + +public class TestClassB +{ + public string StringProperty { get; set; } + + public double DoubleProperty { get; set; } +} + +public class TestClassC +{ + [PrimaryKey] + public int IntProperty { get; set; } + + public double DoubleProperty { get; set; } +} + +public class TestClassD +{ + [PrimaryKey] + public float FloatProperty { get; set; } + + public double DoubleProperty { get; set; } + + public TestClassC ValueC { get; set; } +} + +public class TestClassE +{ + [PrimaryKey] + public Guid TestClassId { get; set; } + + public IEnumerable Values { get; set; } +} + +public class TestClassF +{ + public Guid TestClassId { get; set; } + + public TestClassD Value { get; set; } +} diff --git a/TychoDB.Benchmarks/TychoDB.Benchmarks.csproj b/TychoDB.Benchmarks/TychoDB.Benchmarks.csproj new file mode 100644 index 0000000..aaeab0a --- /dev/null +++ b/TychoDB.Benchmarks/TychoDB.Benchmarks.csproj @@ -0,0 +1,35 @@ + + + Exe + net8.0 + Debug;Release;Encrypted + + + + 4 + + + obj\Release + true + ENCRYPTED; + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TychoDB.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs b/TychoDB.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs new file mode 100644 index 0000000..344eea4 --- /dev/null +++ b/TychoDB.JsonSerializer.NewtonsoftJson/NewtonsoftJsonSerializer.cs @@ -0,0 +1,61 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace TychoDB; + +public class NewtonsoftJsonSerializer : IJsonSerializer +{ + private readonly JsonSerializer _jsonSerializer; + + private readonly JsonSerializerSettings _jsonSerializerSettings; + + public string DateTimeSerializationFormat { get; } + + public NewtonsoftJsonSerializer( + JsonSerializer jsonSerializer = null, + JsonSerializerSettings jsonSerializerSettings = null, + string dateTimeSerializationFormat = "O") + { + DateTimeSerializationFormat = dateTimeSerializationFormat; + + _jsonSerializer = + jsonSerializer ?? + new JsonSerializer + { + DefaultValueHandling = DefaultValueHandling.Include, + NullValueHandling = NullValueHandling.Ignore, + DateFormatString = dateTimeSerializationFormat, + }; + + _jsonSerializerSettings = + jsonSerializerSettings ?? + new JsonSerializerSettings + { + DefaultValueHandling = DefaultValueHandling.Include, + NullValueHandling = NullValueHandling.Include, + DateFormatString = dateTimeSerializationFormat, + }; + } + + public ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken) + { + using var streamReader = new StreamReader(stream); + using var jsonTextReader = + new JsonTextReader(streamReader) + { + DateFormatString = DateTimeSerializationFormat, + }; + + return new ValueTask(_jsonSerializer.Deserialize(jsonTextReader)); + } + + public object Serialize(T obj) + { + return JsonConvert.SerializeObject(obj, _jsonSerializerSettings); + } + + public override string ToString() => nameof(NewtonsoftJsonSerializer); +} diff --git a/TychoDB.JsonSerializer.NewtonsoftJson/TychoDB.JsonSerializer.NewtonsoftJson.csproj b/TychoDB.JsonSerializer.NewtonsoftJson/TychoDB.JsonSerializer.NewtonsoftJson.csproj new file mode 100644 index 0000000..91af17d --- /dev/null +++ b/TychoDB.JsonSerializer.NewtonsoftJson/TychoDB.JsonSerializer.NewtonsoftJson.csproj @@ -0,0 +1,15 @@ + + + + netstandard2.1;NET8.0 + Latest + TychoDB.JsonSerializer.NewtonsoftJson + + + + + + + + \ No newline at end of file diff --git a/TychoDB.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs b/TychoDB.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs new file mode 100644 index 0000000..b88f74c --- /dev/null +++ b/TychoDB.JsonSerializer.SystemTextJson/SystemTextJsonSerializer.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; +using System.Threading; +using System.Threading.Tasks; + +namespace TychoDB; + +public class SystemTextJsonSerializer : IJsonSerializer +{ + private readonly JsonSerializerOptions _jsonSerializerOptions; + + private readonly Dictionary _jsonTypeSerializers; + + public string DateTimeSerializationFormat { get; } + + public SystemTextJsonSerializer( + JsonSerializerOptions jsonSerializerOptions = null, + Dictionary jsonTypeSerializers = null, + string dateTimeSerializationFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") + { + DateTimeSerializationFormat = dateTimeSerializationFormat; + + _jsonSerializerOptions = + jsonSerializerOptions ?? + new JsonSerializerOptions + { + IgnoreReadOnlyProperties = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + }; + + _jsonTypeSerializers = + jsonTypeSerializers + ?? new Dictionary(); + } + + public ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken) + { + if (_jsonTypeSerializers.TryGetValue(typeof(T), out var jsonTypeSerializer) && jsonTypeSerializer is JsonTypeInfo jtst) + { + return JsonSerializer.DeserializeAsync(stream, jtst, cancellationToken); + } + + return JsonSerializer.DeserializeAsync(stream, _jsonSerializerOptions, cancellationToken); + } + + public object Serialize(T obj) + { + if (_jsonTypeSerializers.TryGetValue(typeof(T), out var jsonTypeSerializer) && jsonTypeSerializer is JsonTypeInfo jtst) + { + return JsonSerializer.SerializeToUtf8Bytes(obj, jtst); + } + + return JsonSerializer.SerializeToUtf8Bytes(obj, _jsonSerializerOptions); + } + + public override string ToString() => nameof(SystemTextJsonSerializer); +} diff --git a/TychoDB.JsonSerializer.SystemTextJson/TychoDB.JsonSerializer.SystemTextJson.csproj b/TychoDB.JsonSerializer.SystemTextJson/TychoDB.JsonSerializer.SystemTextJson.csproj new file mode 100644 index 0000000..7ea0734 --- /dev/null +++ b/TychoDB.JsonSerializer.SystemTextJson/TychoDB.JsonSerializer.SystemTextJson.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.1;NET8.0 + Latest + TychoDB.JsonSerializer.SystemTextJson + + + + + + + + \ No newline at end of file diff --git a/TychoDB.JsonSerializer/IJsonSerializer.cs b/TychoDB.JsonSerializer/IJsonSerializer.cs new file mode 100644 index 0000000..527a313 --- /dev/null +++ b/TychoDB.JsonSerializer/IJsonSerializer.cs @@ -0,0 +1,15 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace TychoDB; + +public interface IJsonSerializer +{ + string DateTimeSerializationFormat { get; } + + object Serialize(T obj); + + ValueTask DeserializeAsync(Stream stream, CancellationToken cancellationToken); +} diff --git a/TychoDB.JsonSerializer/TychoDB.JsonSerializer.csproj b/TychoDB.JsonSerializer/TychoDB.JsonSerializer.csproj new file mode 100644 index 0000000..6128145 --- /dev/null +++ b/TychoDB.JsonSerializer/TychoDB.JsonSerializer.csproj @@ -0,0 +1,7 @@ + + + netstandard2.1;NET8.0 + Latest + TychoDB.JsonSerializer + + \ No newline at end of file diff --git a/Tycho.UnitTests/FodyWeavers.xml b/TychoDB.UnitTests/FodyWeavers.xml similarity index 100% rename from Tycho.UnitTests/FodyWeavers.xml rename to TychoDB.UnitTests/FodyWeavers.xml diff --git a/TychoDB.UnitTests/TychoDB.UnitTests.csproj b/TychoDB.UnitTests/TychoDB.UnitTests.csproj new file mode 100644 index 0000000..f2e31f0 --- /dev/null +++ b/TychoDB.UnitTests/TychoDB.UnitTests.csproj @@ -0,0 +1,46 @@ + + + net8.0 + false + Debug;Release;Encrypted + + + TRACE;DEBUG;NET;NET5_0;NETCOREAPP; + 4 + + + + 4 + + + obj\Release\net5.0 + + true + bin\Encrypted\net5.0 + TRACE;RELEASE;NET;NET5_0;NETCOREAPP;ENCRYPTED; + 4 + + 1701;1702 + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tycho.UnitTests/TychoDbTests.cs b/TychoDB.UnitTests/TychoDbTests.cs similarity index 98% rename from Tycho.UnitTests/TychoDbTests.cs rename to TychoDB.UnitTests/TychoDbTests.cs index 4bdd4fe..d8871cc 100644 --- a/Tycho.UnitTests/TychoDbTests.cs +++ b/TychoDB.UnitTests/TychoDbTests.cs @@ -10,10 +10,11 @@ using System.Threading.Tasks; using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; +using TychoDB; [assembly: Parallelize(Scope = ExecutionScope.ClassLevel)] -namespace Tycho.UnitTests; +namespace TychoDB.UnitTests; [TestClass] public class TychoDbTests @@ -88,7 +89,7 @@ public async Task TychoDb_RegisterAndInsertObject_ShouldBeSuccessful(IJsonSerial [DataTestMethod] [DynamicData(nameof(JsonSerializers))] - [ExpectedException(typeof(TychoDbException))] + [ExpectedException(typeof(TychoException))] public async Task TychoDb_InsertObjectWithoutRequiredRegistration_ShouldNotBeSuccessful(IJsonSerializer jsonSerializer) { var db = @@ -130,7 +131,7 @@ public async Task TychoDb_InsertObjectWithRequiredRegistration_ShouldBeSuccessfu [DataTestMethod] [DynamicData(nameof(JsonSerializers))] - [ExpectedException(typeof(TychoDbException))] + [ExpectedException(typeof(TychoException))] public async Task TychoDb_InsertObjectWithRequiredRegistrationAndGenericTypeRegistrationAndNoKeySelector_ShouldThrowError(IJsonSerializer jsonSerializer) { var db = @@ -1669,13 +1670,13 @@ public void TychoDb_ShouldShrinkMemory_IsSuccessful(IJsonSerializer jsonSerializ db.Cleanup(); } - public static TychoDb BuildDatabaseConnection(IJsonSerializer jsonSerializer, bool requireTypeRegistration = false) + public static Tycho BuildDatabaseConnection(IJsonSerializer jsonSerializer, bool requireTypeRegistration = false) { #if ENCRYPTED - return new TychoDb(Path.GetTempPath(), jsonSerializer, $"{Guid.NewGuid()}_cache_enc.db", "Password", rebuildCache: true, requireTypeRegistration: requireTypeRegistration); + return new Tycho(Path.GetTempPath(), jsonSerializer, $"{Guid.NewGuid()}_cache_enc.db", "Password", rebuildCache: true, requireTypeRegistration: requireTypeRegistration); #else - return new TychoDb(Path.GetTempPath(), jsonSerializer, dbName: $"{Guid.NewGuid()}.db", rebuildCache: true, requireTypeRegistration: requireTypeRegistration); + return new Tycho(Path.GetTempPath(), jsonSerializer, dbName: $"{Guid.NewGuid()}.db", rebuildCache: true, requireTypeRegistration: requireTypeRegistration); #endif } } diff --git a/Tycho.sln b/TychoDB.sln similarity index 85% rename from Tycho.sln rename to TychoDB.sln index 7c4f6a6..c1a86b5 100644 --- a/Tycho.sln +++ b/TychoDB.sln @@ -3,20 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.809.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho", "Tycho\Tycho.csproj", "{903AF508-3D99-467C-94D3-133875221FB4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB", "TychoDB\TychoDB.csproj", "{903AF508-3D99-467C-94D3-133875221FB4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho.UnitTests", "Tycho.UnitTests\Tycho.UnitTests.csproj", "{464BA0EF-67B9-4551-9507-A2ED7041C0D1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{999E6276-8388-4D26-BAC9-7EC31A1FC5DE}" - ProjectSection(SolutionItems) = preProject - build.cake = build.cake - build.ps1 = build.ps1 - cakebuild.sh = cakebuild.sh - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB.UnitTests", "TychoDB.UnitTests\TychoDB.UnitTests.csproj", "{464BA0EF-67B9-4551-9507-A2ED7041C0D1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "[Solution Configuration]", "[Solution Configuration]", "{CAE0A9C0-072D-4D8D-9B5F-17D30E3D7EE7}" ProjectSection(SolutionItems) = preProject - icon.png = icon.png + images\logo.png = images\logo.png Directory.build.props = Directory.build.props stylecop.json = stylecop.json .editorconfig = .editorconfig @@ -24,103 +17,108 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "[Solution Configuration]", .gitattributes = .gitattributes EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho.Benchmarks", "Tycho.Benchmarks\Tycho.Benchmarks.csproj", "{2839A1AC-3C12-44BC-80F9-8DE5670AD91A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB.Benchmarks", "TychoDB.Benchmarks\TychoDB.Benchmarks.csproj", "{2839A1AC-3C12-44BC-80F9-8DE5670AD91A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{121BD4F9-4C70-4CB4-961D-F9A0D1E92DD1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho.JsonSerializer", "Tycho.JsonSerializer\Tycho.JsonSerializer.csproj", "{7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB.JsonSerializer", "TychoDB.JsonSerializer\TychoDB.JsonSerializer.csproj", "{7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "JsonSerializers", "JsonSerializers", "{1CF592DF-6EE1-4A6A-97A6-D7662482AA08}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho.JsonSerializer.SystemTextJson", "Tycho.JsonSerializer.SystemTextJson\Tycho.JsonSerializer.SystemTextJson.csproj", "{7F92AAB7-3F45-47CE-BACA-E95E73416ABF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB.JsonSerializer.SystemTextJson", "TychoDB.JsonSerializer.SystemTextJson\TychoDB.JsonSerializer.SystemTextJson.csproj", "{7F92AAB7-3F45-47CE-BACA-E95E73416ABF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tycho.JsonSerializer.NewtonsoftJson", "Tycho.JsonSerializer.NewtonsoftJson\Tycho.JsonSerializer.NewtonsoftJson.csproj", "{884A1B40-F40F-41B2-B149-A8FBF36BE2FD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TychoDB.JsonSerializer.NewtonsoftJson", "TychoDB.JsonSerializer.NewtonsoftJson\TychoDB.JsonSerializer.NewtonsoftJson.csproj", "{884A1B40-F40F-41B2-B149-A8FBF36BE2FD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "[ Build ]", "[ Build ]", "{10D2CA17-47D2-4839-AE54-6CE49229F903}" + ProjectSection(SolutionItems) = preProject + .github\workflows\nuget.yml = .github\workflows\nuget.yml + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - Debug|iPhoneSimulator = Debug|iPhoneSimulator - Release|iPhoneSimulator = Release|iPhoneSimulator Debug|iPhone = Debug|iPhone - Release|iPhone = Release|iPhone + Debug|iPhoneSimulator = Debug|iPhoneSimulator Encrypted|Any CPU = Encrypted|Any CPU + Release|Any CPU = Release|Any CPU + Release|iPhone = Release|iPhone + Release|iPhoneSimulator = Release|iPhoneSimulator EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {903AF508-3D99-467C-94D3-133875221FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {903AF508-3D99-467C-94D3-133875221FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {903AF508-3D99-467C-94D3-133875221FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {903AF508-3D99-467C-94D3-133875221FB4}.Release|Any CPU.Build.0 = Release|Any CPU - {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhone.ActiveCfg = Debug|Any CPU {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhone.Build.0 = Debug|Any CPU + {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {903AF508-3D99-467C-94D3-133875221FB4}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {903AF508-3D99-467C-94D3-133875221FB4}.Encrypted|Any CPU.ActiveCfg = Encrypted|Any CPU {903AF508-3D99-467C-94D3-133875221FB4}.Encrypted|Any CPU.Build.0 = Encrypted|Any CPU + {903AF508-3D99-467C-94D3-133875221FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {903AF508-3D99-467C-94D3-133875221FB4}.Release|Any CPU.Build.0 = Release|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhone.ActiveCfg = Debug|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhone.Build.0 = Debug|Any CPU + {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Encrypted|Any CPU.ActiveCfg = Encrypted|Any CPU + {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {464BA0EF-67B9-4551-9507-A2ED7041C0D1}.Release|Any CPU.Build.0 = Release|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhone.ActiveCfg = Debug|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhone.Build.0 = Debug|Any CPU + {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Encrypted|Any CPU.ActiveCfg = Encrypted|Any CPU + {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2839A1AC-3C12-44BC-80F9-8DE5670AD91A}.Release|Any CPU.Build.0 = Release|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|Any CPU.Build.0 = Release|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhone.ActiveCfg = Debug|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhone.Build.0 = Debug|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhone.ActiveCfg = Release|Any CPU - {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhone.Build.0 = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Encrypted|Any CPU.ActiveCfg = Release|Any CPU {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Encrypted|Any CPU.Build.0 = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|Any CPU.Build.0 = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhone.ActiveCfg = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhone.Build.0 = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Release|Any CPU.Build.0 = Release|Any CPU - {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhone.ActiveCfg = Debug|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhone.Build.0 = Debug|Any CPU + {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Encrypted|Any CPU.ActiveCfg = Release|Any CPU {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Encrypted|Any CPU.Build.0 = Release|Any CPU + {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F92AAB7-3F45-47CE-BACA-E95E73416ABF}.Release|Any CPU.Build.0 = Release|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Release|Any CPU.Build.0 = Release|Any CPU - {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhone.ActiveCfg = Debug|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhone.Build.0 = Debug|Any CPU + {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Encrypted|Any CPU.ActiveCfg = Release|Any CPU {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Encrypted|Any CPU.Build.0 = Release|Any CPU + {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {884A1B40-F40F-41B2-B149-A8FBF36BE2FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3E57D156-945E-4CDD-A3A1-C3ECAD8AF4C2} - EndGlobalSection GlobalSection(NestedProjects) = preSolution {464BA0EF-67B9-4551-9507-A2ED7041C0D1} = {121BD4F9-4C70-4CB4-961D-F9A0D1E92DD1} {2839A1AC-3C12-44BC-80F9-8DE5670AD91A} = {121BD4F9-4C70-4CB4-961D-F9A0D1E92DD1} {7B2BA58E-7460-44E8-B9AE-B93F1EEB31CC} = {1CF592DF-6EE1-4A6A-97A6-D7662482AA08} - {884A1B40-F40F-41B2-B149-A8FBF36BE2FD} = {1CF592DF-6EE1-4A6A-97A6-D7662482AA08} {7F92AAB7-3F45-47CE-BACA-E95E73416ABF} = {1CF592DF-6EE1-4A6A-97A6-D7662482AA08} + {884A1B40-F40F-41B2-B149-A8FBF36BE2FD} = {1CF592DF-6EE1-4A6A-97A6-D7662482AA08} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3E57D156-945E-4CDD-A3A1-C3ECAD8AF4C2} EndGlobalSection EndGlobal diff --git a/Tycho/Filter.cs b/TychoDB/Filter.cs similarity index 99% rename from Tycho/Filter.cs rename to TychoDB/Filter.cs index 4939cb1..444080d 100644 --- a/Tycho/Filter.cs +++ b/TychoDB/Filter.cs @@ -1,7 +1,7 @@ using System; using System.Linq.Expressions; -namespace Tycho; +namespace TychoDB; public enum FilterJoin { diff --git a/Tycho/FilterBuilder.cs b/TychoDB/FilterBuilder.cs similarity index 99% rename from Tycho/FilterBuilder.cs rename to TychoDB/FilterBuilder.cs index 59c4ba3..cc4ecca 100644 --- a/Tycho/FilterBuilder.cs +++ b/TychoDB/FilterBuilder.cs @@ -1,13 +1,10 @@ using System; using System.Collections.Generic; -using System.Dynamic; using System.Linq; using System.Linq.Expressions; -using System.Reflection; using System.Text; -using Microsoft.Data.Sqlite; -namespace Tycho; +namespace TychoDB; public class FilterBuilder { diff --git a/Tycho/ObjectExtensions.cs b/TychoDB/ObjectExtensions.cs similarity index 90% rename from Tycho/ObjectExtensions.cs rename to TychoDB/ObjectExtensions.cs index 5333d57..30477b5 100644 --- a/Tycho/ObjectExtensions.cs +++ b/TychoDB/ObjectExtensions.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Linq.Expressions; -namespace Tycho; +namespace TychoDB; internal static class ObjectExtensions { @@ -21,7 +21,7 @@ public static string GetExpressionMemberName(this Expression method) } } - throw new TychoDbException("The provided expression is not valid member expression"); + throw new TychoException("The provided expression is not valid member expression"); } public static string GetSafeTypeName(this Type type) diff --git a/Tycho/Queries.cs b/TychoDB/Queries.cs similarity index 99% rename from Tycho/Queries.cs rename to TychoDB/Queries.cs index 20fb4b3..91ee173 100644 --- a/Tycho/Queries.cs +++ b/TychoDB/Queries.cs @@ -1,7 +1,7 @@ using System; using System.Linq; -namespace Tycho; +namespace TychoDB; internal static class Queries { diff --git a/Tycho/QueryPropertyPath.cs b/TychoDB/QueryPropertyPath.cs similarity index 99% rename from Tycho/QueryPropertyPath.cs rename to TychoDB/QueryPropertyPath.cs index 30dbbb9..d20af85 100644 --- a/Tycho/QueryPropertyPath.cs +++ b/TychoDB/QueryPropertyPath.cs @@ -5,7 +5,7 @@ using System.Security.Cryptography; using System.Text; -namespace Tycho; +namespace TychoDB; internal static class QueryPropertyPath { diff --git a/Tycho/RegisteredTypeInformation.cs b/TychoDB/RegisteredTypeInformation.cs similarity index 93% rename from Tycho/RegisteredTypeInformation.cs rename to TychoDB/RegisteredTypeInformation.cs index b819fbb..984bbd6 100644 --- a/Tycho/RegisteredTypeInformation.cs +++ b/TychoDB/RegisteredTypeInformation.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; -using System.Reflection; -using System.Runtime.InteropServices; -namespace Tycho; +namespace TychoDB; public class RegisteredTypeInformation { @@ -37,7 +34,7 @@ public Func GetIdSelector() { if (RequiresIdMapping) { - throw new TychoDbException($"An id mapping has not been provided for {TypeName}"); + throw new TychoException($"An id mapping has not been provided for {TypeName}"); } return (Func)IdSelector; @@ -52,7 +49,7 @@ public bool CompareIdsFor(T obj1, T obj2) { if (RequiresIdMapping) { - throw new TychoDbException($"An id mapping has not been provided for {TypeName}"); + throw new TychoException($"An id mapping has not been provided for {TypeName}"); } var id1 = GetIdFor(obj1); diff --git a/Tycho/SortBuilder.cs b/TychoDB/SortBuilder.cs similarity index 93% rename from Tycho/SortBuilder.cs rename to TychoDB/SortBuilder.cs index b3afdb9..aa9bb25 100644 --- a/Tycho/SortBuilder.cs +++ b/TychoDB/SortBuilder.cs @@ -1,13 +1,10 @@ using System; using System.Collections.Generic; -using System.Dynamic; using System.Linq; using System.Linq.Expressions; -using System.Reflection; using System.Text; -using Microsoft.Data.Sqlite; -namespace Tycho; +namespace TychoDB; public class SortBuilder { diff --git a/Tycho/SortInfo.cs b/TychoDB/SortInfo.cs similarity index 95% rename from Tycho/SortInfo.cs rename to TychoDB/SortInfo.cs index 33238d5..08b08c5 100644 --- a/Tycho/SortInfo.cs +++ b/TychoDB/SortInfo.cs @@ -1,7 +1,7 @@ using System; using System.Linq.Expressions; -namespace Tycho; +namespace TychoDB; public enum SortDirection { diff --git a/Tycho/TychoDb.cs b/TychoDB/Tycho.cs similarity index 92% rename from Tycho/TychoDb.cs rename to TychoDB/Tycho.cs index 9fa9913..13014d2 100644 --- a/Tycho/TychoDb.cs +++ b/TychoDB/Tycho.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Data; -using System.Data.Common; using System.IO; using System.Linq; using System.Linq.Expressions; @@ -11,9 +10,9 @@ using System.Threading.Tasks; using Microsoft.Data.Sqlite; -namespace Tycho; +namespace TychoDB; -public class TychoDb : IDisposable +public class Tycho : IDisposable { private const string ParameterFullTypeName = "$fullTypeName", @@ -61,7 +60,17 @@ private StringBuilder ReusableStringBuilder } } - public TychoDb(string dbPath, IJsonSerializer jsonSerializer, string dbName = "tycho_cache.db", string password = null, bool persistConnection = true, bool rebuildCache = false, bool requireTypeRegistration = true) + /// + /// Initializes a new instance of the class. + /// + /// The path to the directory where the database file will be stored. + /// The JSON serializer used for serializing and deserializing objects. + /// The name of the database file. Default is "tycho_cache.db". + /// The password for the database file. Default is null. + /// Indicates whether the database connection should be persisted. Default is true. + /// Indicates whether to rebuild the cache by deleting the existing database file. Default is false. + /// Indicates whether type registration is required. Default is true. + public Tycho(string dbPath, IJsonSerializer jsonSerializer, string dbName = "tycho_cache.db", string password = null, bool persistConnection = true, bool rebuildCache = false, bool requireTypeRegistration = true) { SQLitePCL.Batteries_V2.Init(); @@ -94,7 +103,7 @@ public TychoDb(string dbPath, IJsonSerializer jsonSerializer, string dbName = "t _requireTypeRegistration = requireTypeRegistration; } - public TychoDb AddTypeRegistration( + public Tycho AddTypeRegistration( Expression> idPropertySelector, EqualityComparer idComparer = null) where T : class @@ -106,7 +115,7 @@ public TychoDb AddTypeRegistration( return this; } - public TychoDb AddTypeRegistration() + public Tycho AddTypeRegistration() where T : class { var rti = RegisteredTypeInformation.Create(); @@ -116,7 +125,7 @@ public TychoDb AddTypeRegistration() return this; } - public TychoDb AddTypeRegistrationWithCustomKeySelector( + public Tycho AddTypeRegistrationWithCustomKeySelector( Func keySelector, EqualityComparer idComparer = null) where T : class @@ -128,7 +137,7 @@ public TychoDb AddTypeRegistrationWithCustomKeySelector( return this; } - public TychoDb Connect() + public Tycho Connect() { if (_connection != null) { @@ -140,7 +149,7 @@ public TychoDb Connect() return this; } - public async ValueTask ConnectAsync() + public async ValueTask ConnectAsync() { if (_connection != null) { @@ -207,8 +216,7 @@ public ValueTask WriteObjectsAsync(IEnumerable objs, Func { var successful = false; var writeCount = 0; - var objsArray = objs as T[] ?? objs.ToArray(); - var totalCount = objsArray.Length; + var potentialTotalCount = 0; SqliteTransaction transaction = null; @@ -233,8 +241,9 @@ public ValueTask WriteObjectsAsync(IEnumerable objs, Func .Add(ParameterPartition, SqliteType.Text) .Value = partition.AsValueOrEmptyString(); - foreach (var obj in objsArray) + foreach (var obj in objs) { + ++potentialTotalCount; keyParameter.Value = keySelector(obj); jsonParameter.Value = _jsonSerializer.Serialize(obj); @@ -243,7 +252,7 @@ public ValueTask WriteObjectsAsync(IEnumerable objs, Func writeCount += rowId > 0 ? 1 : 0; } - successful = writeCount == totalCount; + successful = writeCount == potentialTotalCount; if (successful) { @@ -257,7 +266,7 @@ public ValueTask WriteObjectsAsync(IEnumerable objs, Func catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Writing Objects", ex); + throw new TychoException($"Failed Writing Objects", ex); } finally { @@ -325,7 +334,7 @@ public ValueTask CountObjectsAsync(string partition = null, FilterBuilde catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Reading Objects", ex); + throw new TychoException($"Failed Reading Objects", ex); } finally { @@ -391,7 +400,7 @@ public ValueTask ObjectExistsAsync(object key, string partition = null, catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Reading Object with key \"{key}\"", ex); + throw new TychoException($"Failed Reading Object with key \"{key}\"", ex); } finally { @@ -458,7 +467,7 @@ public ValueTask ReadObjectAsync(object key, string partition = null, bool catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Reading Object with key \"{key}\"", ex); + throw new TychoException($"Failed Reading Object with key \"{key}\"", ex); } finally { @@ -491,7 +500,7 @@ public async ValueTask ReadObjectAsync( if (matches > 1) { - throw new TychoDbException("Too many matching values were found, please refine your query to limit it to a single match"); + throw new TychoException("Too many matching values were found, please refine your query to limit it to a single match"); } var results = @@ -572,7 +581,7 @@ public ValueTask> ReadObjectsAsync( catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Reading Objects", ex); + throw new TychoException($"Failed Reading Objects", ex); } finally { @@ -661,7 +670,7 @@ public async ValueTask> ReadObjectsAsync( catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException("Failed Reading Objects", ex); + throw new TychoException("Failed Reading Objects", ex); } finally { @@ -723,7 +732,7 @@ public ValueTask DeleteObjectAsync(object key, string partition = null, catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed to delete object with key \"{key}\"", ex); + throw new TychoException($"Failed to delete object with key \"{key}\"", ex); } finally { @@ -782,7 +791,7 @@ public ValueTask DeleteObjectsAsync(string partition = null, FilterBuild catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException("Failed to delete objects", ex); + throw new TychoException("Failed to delete objects", ex); } finally { @@ -835,7 +844,7 @@ public ValueTask WriteBlobAsync(Stream stream, object key, string partitio catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed Writing Objects", ex); + throw new TychoException($"Failed Writing Objects", ex); } finally { @@ -883,7 +892,7 @@ public ValueTask BlobExistsAsync(object key, string partition = null, Canc } catch (Exception ex) { - throw new TychoDbException($"Failed Reading Object with key \"{key}\"", ex); + throw new TychoException($"Failed Reading Object with key \"{key}\"", ex); } }, _persistConnection, @@ -925,7 +934,7 @@ public ValueTask ReadBlobAsync(object key, string partition = null, Canc } catch (Exception ex) { - throw new TychoDbException($"Failed Reading Object with key \"{key}\"", ex); + throw new TychoException($"Failed Reading Object with key \"{key}\"", ex); } }, _persistConnection, @@ -970,7 +979,7 @@ public ValueTask DeleteBlobAsync(object key, string partition = null, bool catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException($"Failed to delete object with key \"{key}\"", ex); + throw new TychoException($"Failed to delete object with key \"{key}\"", ex); } finally { @@ -1017,7 +1026,7 @@ public ValueTask DeleteBlobAsync(object key, string partition = null, bool catch (Exception ex) { transaction?.Rollback(); - throw new TychoDbException("Failed to delete objects", ex); + throw new TychoException("Failed to delete objects", ex); } finally { @@ -1028,7 +1037,7 @@ public ValueTask DeleteBlobAsync(object key, string partition = null, bool cancellationToken); } - public TychoDb CreateIndex(Expression> propertyPath, string indexName) + public Tycho CreateIndex(Expression> propertyPath, string indexName) { if (_requireTypeRegistration) { @@ -1038,7 +1047,7 @@ public TychoDb CreateIndex(Expression> propertyPath, st return CreateIndex(QueryPropertyPath.BuildPath(propertyPath), QueryPropertyPath.IsNumeric(propertyPath), GetSafeTypeName(), indexName); } - public TychoDb CreateIndex(string propertyPathString, bool isNumeric, string objectTypeName, string indexName) + public Tycho CreateIndex(string propertyPathString, bool isNumeric, string objectTypeName, string indexName) { _connection .WithConnectionBlock( @@ -1072,7 +1081,7 @@ public TychoDb CreateIndex(string propertyPathString, bool isNumeric, string obj catch (Exception ex) { transaction.Rollback(); - throw new TychoDbException($"Failed to Create Index: {fullIndexName}", ex); + throw new TychoException($"Failed to Create Index: {fullIndexName}", ex); } }, _persistConnection); @@ -1119,7 +1128,7 @@ public ValueTask CreateIndexAsync(string propertyPathString, bool isNumeri catch (Exception ex) { transaction.Rollback(); - throw new TychoDbException($"Failed to Create Index: {fullIndexName}", ex); + throw new TychoException($"Failed to Create Index: {fullIndexName}", ex); } return true; @@ -1128,7 +1137,7 @@ public ValueTask CreateIndexAsync(string propertyPathString, bool isNumeri cancellationToken); } - public TychoDb CreateIndex(Expression>[] propertyPaths, string indexName) + public Tycho CreateIndex(Expression>[] propertyPaths, string indexName) { if (_requireTypeRegistration) { @@ -1163,7 +1172,7 @@ public TychoDb CreateIndex(Expression>[] propertyPaths, catch (Exception ex) { transaction.Rollback(); - throw new TychoDbException($"Failed to Create Index: {fullIndexName}", ex); + throw new TychoException($"Failed to Create Index: {fullIndexName}", ex); } }, _persistConnection); @@ -1207,7 +1216,7 @@ public ValueTask CreateIndexAsync(Expression>[] p catch (Exception ex) { transaction.Rollback(); - throw new TychoDbException($"Failed to Create Index: {fullIndexName}", ex); + throw new TychoException($"Failed to Create Index: {fullIndexName}", ex); } return true; @@ -1247,7 +1256,7 @@ public void Cleanup(bool shrinkMemory = true, bool vacuum = false) } catch (Exception ex) { - throw new TychoDbException($"Failed to shrink memory", ex); + throw new TychoException($"Failed to shrink memory", ex); } }, _persistConnection); @@ -1380,7 +1389,7 @@ private SqliteConnection BuildConnection() if (!supportsJson) { conn.Close(); - throw new TychoDbException("JSON support is not available for this platform"); + throw new TychoException("JSON support is not available for this platform"); } using var command = connection.CreateCommand(); @@ -1423,7 +1432,7 @@ private async ValueTask BuildConnectionAsync(CancellationToken if (!supportsJson) { _connection.Close(); - throw new TychoDbException("JSON support is not available for this platform"); + throw new TychoException("JSON support is not available for this platform"); } using var command = _connection.CreateCommand(); @@ -1447,7 +1456,7 @@ private void CheckHasRegisteredType(Type type) { if (!_registeredTypeInformation.ContainsKey(type)) { - throw new TychoDbException($"Registration missing for type: {type}"); + throw new TychoException($"Registration missing for type: {type}"); } } } @@ -1458,7 +1467,7 @@ public static T WithConnectionBlock(this SqliteConnection connection, RateLim { if (connection == null) { - throw new TychoDbException("Please call 'Connect' before performing an operation"); + throw new TychoException("Please call 'Connect' before performing an operation"); } using var rla = rateLimiter.AttemptAcquire(); @@ -1485,7 +1494,7 @@ public static void WithConnectionBlock(this SqliteConnection connection, RateLim { if (connection == null) { - throw new TychoDbException("Please call 'Connect' before performing an operation"); + throw new TychoException("Please call 'Connect' before performing an operation"); } using var rla = rateLimiter.AttemptAcquire(); @@ -1512,7 +1521,7 @@ public static async ValueTask WithConnectionBlockAsync(this SqliteConnecti { if (connection == null) { - throw new TychoDbException("Please call 'Connect' before performing an operation"); + throw new TychoException("Please call 'Connect' before performing an operation"); } using var rla = await rateLimiter.AcquireAsync(cancellationToken: cancellationToken).ConfigureAwait(false); @@ -1539,7 +1548,7 @@ public static async ValueTask WithConnectionBlockAsync(this SqliteConnecti { if (connection == null) { - throw new TychoDbException("Please call 'Connect' before performing an operation"); + throw new TychoException("Please call 'Connect' before performing an operation"); } using var rla = await rateLimiter.AcquireAsync(cancellationToken: cancellationToken).ConfigureAwait(false); diff --git a/TychoDB/Tycho.csproj b/TychoDB/Tycho.csproj new file mode 100644 index 0000000..5888c5f --- /dev/null +++ b/TychoDB/Tycho.csproj @@ -0,0 +1,48 @@ + + + + netstandard2.1;NET7.0 + Latest + Tycho + Encrypted;Debug;Release + + + obj\Encrypted + true + bin\Encrypted + TRACE;RELEASE;ENCRYPTED;NETSTANDARD;NETSTANDARD2_1; + Latest + true + TychoDB.Encrypted + + + true + false + false + false + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TychoDB/TychoDB.csproj b/TychoDB/TychoDB.csproj new file mode 100644 index 0000000..92d68ee --- /dev/null +++ b/TychoDB/TychoDB.csproj @@ -0,0 +1,38 @@ + + + + netstandard2.1;NET8.0 + Latest + TychoDB + Encrypted;Debug;Release + + + obj\Encrypted + true + bin\Encrypted + TRACE;RELEASE;ENCRYPTED;NETSTANDARD;NETSTANDARD2_1; + Latest + true + TychoDB.Encrypted + + + true + false + false + false + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TychoDB/TychoException.cs b/TychoDB/TychoException.cs new file mode 100644 index 0000000..687ab46 --- /dev/null +++ b/TychoDB/TychoException.cs @@ -0,0 +1,21 @@ +using System; +using System.Runtime.Serialization; + +namespace TychoDB; + +public class TychoException : Exception +{ + public TychoException() + { + } + + public TychoException(string message) + : base(message) + { + } + + public TychoException(string message, Exception innerException) + : base(message, innerException) + { + } +} diff --git a/build.cake b/build.cake index db5ec39..c783d6c 100644 --- a/build.cake +++ b/build.cake @@ -25,7 +25,7 @@ var buildType = Argument("build_type", "Release"); ////////////////////////////////////////////////////////////////////// // PREPARATION ////////////////////////////////////////////////////////////////////// -var mainSolution = "Tycho.sln"; +var mainSolution = "TychoDB.sln"; var eightbotNugetUsername = "eightbot"; var eightbotNugetSourceName = "Eight-Bot"; @@ -37,7 +37,7 @@ var eightbotNugetSourceUrl = "https://eightbot.pkgs.visualstudio.com/_packaging/ Setup(context => { Information("Building Tycho"); - Information("Nuget API Key: "+ eightbotNugetApiKey); + Information("Nuget API Key: " + eightbotNugetApiKey); }); Teardown(context => @@ -48,61 +48,62 @@ Teardown(context => ////////////////////////////////////////////////////////////////////// // TASKS ////////////////////////////////////////////////////////////////////// -Task ("Clean") -.Does (() => +Task("Clean") +.Does(() => { - CleanDirectories ("./Tycho/bin"); - CleanDirectories ("./Tycho/obj"); - CleanDirectories ("./Tycho*/bin"); - CleanDirectories ("./Tycho*/obj"); + CleanDirectories("./Tycho/bin"); + CleanDirectories("./Tycho/obj"); + CleanDirectories("./Tycho*/bin"); + CleanDirectories("./Tycho*/obj"); var nugetPackages = GetFiles("./*.nupkg"); DeleteFiles(nugetPackages); }); -Task ("RestorePackages") -.Does (() => +Task("RestorePackages") +.Does(() => { - if(NuGetHasSource(source:eightbotNugetSourceUrl)) { + if (NuGetHasSource(source: eightbotNugetSourceUrl)) + { NuGetRemoveSource(eightbotNugetSourceName, eightbotNugetSourceUrl); } NuGetAddSource( name: eightbotNugetSourceName, source: eightbotNugetSourceUrl, - settings: new NuGetSourcesSettings - { - UserName = eightbotNugetUsername, - Password = eightbotNugetApiKey, - IsSensitiveSource = true, - Verbosity = NuGetVerbosity.Detailed - }); - - NuGetRestore(mainSolution); + settings: new NuGetSourcesSettings + { + UserName = eightbotNugetUsername, + Password = eightbotNugetApiKey, + IsSensitiveSource = true, + Verbosity = NuGetVerbosity.Detailed + }); + + NuGetRestore(mainSolution); }); -Task ("BuildCore") +Task("BuildCore") .IsDependentOn("Clean") .IsDependentOn("RestorePackages") -.Does (() => +.Does(() => { var buildSettings = - new MSBuildSettings{} - .WithProperty("Version", version) - .WithProperty("ReleaseVersion", version) - .WithProperty("PackageVersion", version) - .SetMaxCpuCount(1) - .SetVerbosity(Verbosity.Quiet) - .SetConfiguration(buildType) - .SetPlatformTarget(PlatformTarget.MSIL); - - if (IsRunningOnWindows()) - { + new MSBuildSettings { } + .WithProperty("Version", version) + .WithProperty("ReleaseVersion", version) + .WithProperty("PackageVersion", version) + .SetMaxCpuCount(1) + .SetVerbosity(Verbosity.Quiet) + .SetConfiguration(buildType) + .SetPlatformTarget(PlatformTarget.MSIL); + + if (IsRunningOnWindows()) + { buildSettings = buildSettings - .UseToolVersion(MSBuildToolVersion.VS2019) - .SetMSBuildPlatform(MSBuildPlatform.x86); - } + .UseToolVersion(MSBuildToolVersion.VS2019) + .SetMSBuildPlatform(MSBuildPlatform.x86); + } MSBuild(mainSolution, buildSettings); }); @@ -111,11 +112,12 @@ Task("NuGet") .IsDependentOn("BuildCore") .Does(() => { - var nugetPackages = GetFiles("./**/EightBot.Tycho.*.nupkg"); + var nugetPackages = GetFiles("./**/EightBot.TychoDB.*.nupkg"); - foreach(var package in nugetPackages) { + foreach (var package in nugetPackages) + { - var processArguments = new ProcessArgumentBuilder{}; + var processArguments = new ProcessArgumentBuilder { }; processArguments .Append("push") @@ -127,10 +129,11 @@ Task("NuGet") .Append("-SkipDuplicate"); - using(var process = + using (var process = StartAndReturnProcess( "nuget", - new ProcessSettings{ + new ProcessSettings + { Arguments = processArguments } )) diff --git a/icon.png b/images/logo.png similarity index 100% rename from icon.png rename to images/logo.png