Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.0.0" />
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageVersion Include="System.IO.Hashing" Version="9.0.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="FluentAssertions" Version="7.0.0-alpha.6" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="JetBrains.Profiler.SelfApi" Version="2.5.12" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.IO.Hashing" Version="10.0.7" />
<PackageVersion Include="System.Linq.Async" Version="7.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="FluentAssertions" Version="8.9.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageVersion Include="JetBrains.Profiler.SelfApi" Version="2.5.18" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageVersion Include="System.Text.Json" Version="10.0.7" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.EntityFramework" Version="12.4.0" />
<PackageVersion Include="Verify.Xunit" Version="28.2.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19" />
<PackageVersion Include="linq2db.AspNet" Version="5.4.1" />
<PackageVersion Include="linq2db.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Verify.EntityFramework" Version="15.1.0" />
<PackageVersion Include="Verify.XunitV3" Version="31.16.2" />
<PackageVersion Include="xunit.v3" Version="3.2.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="coverlet.collector" Version="10.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15" />
<PackageVersion Include="linq2db" Version="6.2.1" />
<PackageVersion Include="linq2db.EntityFrameworkCore" Version="10.3.0" />
<PackageVersion Include="linq2db.Extensions" Version="6.2.1" />
<PackageVersion Include="EFCore.ComplexIndexes" Version="2.0.2" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/SIL.Harmony.Linq2db/Linq2dbKernel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SIL.Harmony.Core;
using LinqToDB.AspNet.Logging;
using LinqToDB.EntityFrameworkCore;
using LinqToDB.Extensions.Logging;
using LinqToDB.Mapping;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
Expand Down
2 changes: 1 addition & 1 deletion src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="linq2db.AspNet" />
<PackageReference Include="linq2db.EntityFrameworkCore" />
<PackageReference Include="linq2db.Extensions" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/SIL.Harmony.Tests/Adapter/CustomObjectAdapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public async Task CanAdaptACustomObject()
.Add<MyClass2>(builder => builder.HasKey(o => o.Identifier));
}).BuildServiceProvider();
var myDbContext = services.GetRequiredService<MyDbContext>();
await myDbContext.Database.OpenConnectionAsync();
await myDbContext.Database.EnsureCreatedAsync();
await myDbContext.Database.OpenConnectionAsync(TestContext.Current.CancellationToken);
await myDbContext.Database.EnsureCreatedAsync(TestContext.Current.CancellationToken);
var dataModel = services.GetRequiredService<DataModel>();
var objectId = Guid.NewGuid();
var objectId2 = Guid.NewGuid();
Expand Down Expand Up @@ -194,6 +194,6 @@ await dataModel.AddChange(Guid.NewGuid(),
myClass2.MyNumber.Should().Be(123.45m);
myClass2.DeletedTime.Should().BeNull();

dataModel.QueryLatest<MyClass>().ToBlockingEnumerable().Should().NotBeEmpty();
dataModel.QueryLatest<MyClass>().ToBlockingEnumerable(TestContext.Current.CancellationToken).Should().NotBeEmpty();
}
}
1 change: 0 additions & 1 deletion src/SIL.Harmony.Tests/DataModelPerformanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using SIL.Harmony.Changes;
using SIL.Harmony.Db;
using SIL.Harmony.Sample.Changes;
using Xunit.Abstractions;

namespace SIL.Harmony.Tests;

Expand Down Expand Up @@ -74,7 +73,7 @@
return total / iterations;
}

[Fact]

Check failure on line 76 in src/SIL.Harmony.Tests/DataModelPerformanceTests.cs

View workflow job for this annotation

GitHub Actions / build

SIL.Harmony.Tests.DataModelPerformanceTests.SimpleAddChangePerformanceTest

Expected runtimeAddChange10000Snapshots to be within 10ms and 923.2µs from 2ms and 730.8µs, but found 19ms and 519.3µs.

Check failure on line 76 in src/SIL.Harmony.Tests/DataModelPerformanceTests.cs

View workflow job for this annotation

GitHub Actions / build

SIL.Harmony.Tests.DataModelPerformanceTests.SimpleAddChangePerformanceTest

Expected runtimeAddChange10000Snapshots to be within 12ms and 176.4µs from 3ms and 44.1µs, but found 18ms and 769.4µs.
public async Task SimpleAddChangePerformanceTest()
{
//disable validation because it's slow
Expand Down
24 changes: 12 additions & 12 deletions src/SIL.Harmony.Tests/DataModelReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DataModelReferenceTests : DataModelTestBase
private readonly Guid _word1Id = Guid.NewGuid();
private readonly Guid _word2Id = Guid.NewGuid();

public override async Task InitializeAsync()
public override async ValueTask InitializeAsync()
{
await base.InitializeAsync();
await WriteNextChange(SetWord(_word1Id, "entity1"));
Expand Down Expand Up @@ -41,7 +41,7 @@ public async Task AddReferenceWorks(bool includeObjectInSnapshot)

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync();
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.AntonymId.Should().Be(_word2Id);
entityWord.Antonym.Should().NotBeNull();
Expand Down Expand Up @@ -80,7 +80,7 @@ await WriteNextChange(

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == word3Id).SingleOrDefaultAsync();
.Where(w => w.Id == word3Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.AntonymId.Should().Be(_word2Id);
entityWord.Antonym.Should().NotBeNull();
Expand Down Expand Up @@ -118,7 +118,7 @@ await WriteNextChange(new SetAntonymReferenceChange(word3Id, _word2Id, setObject

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == word3Id).SingleOrDefaultAsync();
.Where(w => w.Id == word3Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.AntonymId.Should().Be(_word2Id);
entityWord.Antonym.Should().NotBeNull();
Expand Down Expand Up @@ -157,7 +157,7 @@ await WriteNextChange(

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == word3Id).SingleOrDefaultAsync();
.Where(w => w.Id == word3Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.Text.Should().Be("entity3");
entityWord.AntonymId.Should().Be(_word1Id);
Expand Down Expand Up @@ -197,7 +197,7 @@ await WriteNextChange(

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync();
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.Text.Should().Be("entity1");
entityWord.AntonymId.Should().Be(word3Id);
Expand Down Expand Up @@ -236,7 +236,7 @@ await WriteNextChange(new SetAntonymReferenceChange(word3Id, _word1Id, setObject

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == word3Id).SingleOrDefaultAsync();
.Where(w => w.Id == word3Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.Text.Should().Be("entity3");
entityWord.AntonymId.Should().Be(_word1Id);
Expand Down Expand Up @@ -275,7 +275,7 @@ await WriteNextChange(new SetAntonymReferenceChange(_word1Id, word3Id, setObject

// assert - projected entity
var entityWord = await DataModel.QueryLatest<Word>(w => w.Include(w => w.Antonym))
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync();
.Where(w => w.Id == _word1Id).SingleOrDefaultAsync(TestContext.Current.CancellationToken);
entityWord.Should().NotBeNull();
entityWord.Text.Should().Be("entity1");
entityWord.AntonymId.Should().Be(word3Id);
Expand Down Expand Up @@ -341,10 +341,10 @@ await AddCommitsViaSync([
initialWordCommit,
deleteWordCommit
]);
var snapshot = await DbContext.Snapshots.SingleAsync(s => s.CommitId == initialWordCommit.Id);
var snapshot = await DbContext.Snapshots.SingleAsync(s => s.CommitId == initialWordCommit.Id, TestContext.Current.CancellationToken);
var initialWord = (Word) snapshot.Entity;
initialWord.AntonymId.Should().Be(_word1Id);
snapshot = await DbContext.Snapshots.SingleAsync(s => s.CommitId == deleteWordCommit.Id && s.EntityId == wordId);
snapshot = await DbContext.Snapshots.SingleAsync(s => s.CommitId == deleteWordCommit.Id && s.EntityId == wordId, TestContext.Current.CancellationToken);
var wordWithoutRef = (Word) snapshot.Entity;
wordWithoutRef.AntonymId.Should().BeNull();
}
Expand Down Expand Up @@ -422,7 +422,7 @@ public async Task CanCreate2TagsWithTheSameNameOutOfOrder()
var commitA = await WriteNextChange(SetTag(Guid.NewGuid(), tagText));
//represents someone syncing in a tag with the same name
await WriteChangeBefore(commitA, SetTag(Guid.NewGuid(), tagText));
DataModel.QueryLatest<Tag>().ToBlockingEnumerable().Where(t => t.Text == tagText).Should().ContainSingle();
DataModel.QueryLatest<Tag>().ToBlockingEnumerable(TestContext.Current.CancellationToken).Where(t => t.Text == tagText).Should().ContainSingle();
}

[Fact]
Expand All @@ -434,6 +434,6 @@ public async Task CanUpdateTagWithTheSameNameOutOfOrder()
var commitA = await WriteNextChange(SetTag(Guid.NewGuid(), tagText));
//represents someone syncing in a tag with the same name
await WriteNextChange(SetTag(renameTagId, tagText));
DataModel.QueryLatest<Tag>().ToBlockingEnumerable().Where(t => t.Text == tagText).Should().ContainSingle();
DataModel.QueryLatest<Tag>().ToBlockingEnumerable(TestContext.Current.CancellationToken).Where(t => t.Text == tagText).Should().ContainSingle();
}
}
16 changes: 8 additions & 8 deletions src/SIL.Harmony.Tests/DataModelSimpleChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task WriteMultipleCommits()

await WriteNextChange(SetWord(Guid.NewGuid(), "change 3"));
DbContext.Snapshots.Should().HaveCount(3);
DataModel.QueryLatest<Word>().ToBlockingEnumerable().Should().HaveCount(3);
DataModel.QueryLatest<Word>().ToBlockingEnumerable(TestContext.Current.CancellationToken).Should().HaveCount(3);
}

[Fact]
Expand All @@ -95,7 +95,7 @@ public async Task Writing2ChangesSecondOverwritesFirst()
{
await WriteNextChange(SetWord(_entity1Id, "first"));
await WriteNextChange(SetWord(_entity1Id, "second"));
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
snapshot.Entity.Is<Word>().Text.Should().Be("second");
}

Expand All @@ -107,7 +107,7 @@ public async Task CanWriteChangesWhenAnUnchangedWordExists()
await WriteNextChange(SetWord(_entity1Id, "word-1"));
await WriteNextChange(SetWord(_entity1Id, "second"));
await WriteNextChange(SetWord(_entity1Id, "third"));
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
snapshot.Entity.Is<Word>().Text.Should().Be("third");
}

Expand All @@ -118,7 +118,7 @@ public async Task Writing2ChangesSecondOverwritesFirstWithLocalFirst()
var secondDate = DateTimeOffset.UtcNow.AddSeconds(1);
await WriteChange(_localClientId, firstDate, SetWord(_entity1Id, "first"));
await WriteChange(_localClientId, secondDate, SetWord(_entity1Id, "second"));
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
snapshot.Entity.Is<Word>().Text.Should().Be("second");
}

Expand All @@ -129,7 +129,7 @@ public async Task Writing2ChangesSecondOverwritesFirstWithUtcFirst()
var secondDate = DateTimeOffset.Now.AddSeconds(1);
await WriteChange(_localClientId, firstDate, SetWord(_entity1Id, "first"));
await WriteChange(_localClientId, secondDate, SetWord(_entity1Id, "second"));
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
snapshot.Entity.Is<Word>().Text.Should().Be("second");
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public async Task CanDeleteAnEntry()
{
await WriteNextChange(SetWord(_entity1Id, "test-value"));
var deleteCommit = await WriteNextChange(new DeleteChange<Word>(_entity1Id));
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
snapshot.Entity.DeletedAt.Should().Be(deleteCommit.DateTime);
}

Expand All @@ -198,7 +198,7 @@ public async Task ApplyChange_ModifiesADeletedEntry()
newNoteChange.SupportsApplyChange().Should().BeTrue();
newNoteChange.SupportsNewEntity().Should().BeFalse(); // otherwise it will override the delete
await WriteNextChange(newNoteChange);
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
var word = snapshot.Entity.Is<Word>();
word.Text.Should().Be("test-value");
word.Note.Should().Be("note-after-delete");
Expand All @@ -213,7 +213,7 @@ public async Task NewEntity_UndeletesAnEntry()
var recreateChange = SetWord(_entity1Id, "after-undo-delete");
recreateChange.SupportsNewEntity().Should().BeTrue();
await WriteNextChange(recreateChange);
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync();
var snapshot = await DbContext.Snapshots.DefaultOrder().LastAsync(TestContext.Current.CancellationToken);
var word = snapshot.Entity.Is<Word>();
word.Text.Should().Be("after-undo-delete");
word.DeletedAt.Should().Be(null);
Expand Down
6 changes: 3 additions & 3 deletions src/SIL.Harmony.Tests/DataModelTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ public IChange NewDefinition(Guid wordId,
};
}

public virtual Task InitializeAsync()
public virtual ValueTask InitializeAsync()
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{

await _services.DisposeAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/SIL.Harmony.Tests/DataQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SIL.Harmony.Tests;
public class DataQueryTests: DataModelTestBase
{
private readonly Guid _entity1Id = Guid.NewGuid();
public override async Task InitializeAsync()
public override async ValueTask InitializeAsync()
{
await base.InitializeAsync();
await WriteNextChange(SetWord(_entity1Id, "entity1"));
Expand All @@ -15,7 +15,7 @@ public override async Task InitializeAsync()
[Fact]
public async Task CanQueryLatestData()
{
var entries = await DataModel.QueryLatest<Word>().ToArrayAsync();
var entries = await DataModel.QueryLatest<Word>().ToArrayAsync(TestContext.Current.CancellationToken);
var entry = entries.Should().ContainSingle().Subject;
entry.Text.Should().Be("entity1");
}
Expand Down
Loading
Loading