Skip to content

Commit

Permalink
Update to dotnet7 and update of mongo driver library. (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
nscheibe committed Nov 30, 2022
1 parent fa74173 commit d2c7b75
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 36 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "7.0.100",
"rollForward": "latestFeature"
}
}
6 changes: 3 additions & 3 deletions samples/Context/DataAccess/DataAccess.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<AssemblyName>SimpleBlog.DataAccess</AssemblyName>
<RootNamespace>SimpleBlog.DataAccess</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions samples/Context/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<AssemblyName>SimpleBlog.Domain</AssemblyName>
<RootNamespace>SimpleBlog.Domain</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions samples/Context/Host/Host.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>fbbac7be-63d2-4849-8dc4-31492a2367a2</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
Expand All @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="NSwag.AspNetCore" Version="13.15.3" />
<PackageReference Include="Squadron.Mongo" Version="0.13.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="NSwag.AspNetCore" Version="13.18.0" />
<PackageReference Include="Squadron.Mongo" Version="0.17.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Context/Models/Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<AssemblyName>SimpleBlog.Models</AssemblyName>
<RootNamespace>SimpleBlog.Models</RootNamespace>
<IsPackable>false</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions samples/Migration/Migration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.15.1" />
<PackageReference Include="MongoDB.Extensions.Migration" Version="1.3.0-preview1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Extensions.Migration" Version="1.4.0" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/Context.Tests/Context.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<Compile Remove="IsExternalInit.cs" Condition="'$(TargetFramework)' == 'net6.0'" />
<Compile Remove="IsExternalInit.cs" Condition="'$(TargetFramework)' == 'net7.0'" />
</ItemGroup>

</Project>
10 changes: 8 additions & 2 deletions src/Context/Context.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.1.0" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup Label="Framework Versions">
<TestProjectTargetFrameworks>netcoreapp3.1;net5.0;net6.0</TestProjectTargetFrameworks>
<ResourceProjectTargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0</ResourceProjectTargetFrameworks>
<TestProjectTargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</TestProjectTargetFrameworks>
<ResourceProjectTargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0</ResourceProjectTargetFrameworks>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Migration.Tests/Migration.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<AssemblyName>Migration.Tests</AssemblyName>
<RootNamespace>Migration.Tests</RootNamespace>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Migration/Migration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<AssemblyName>MongoDB.Extensions.Migration</AssemblyName>
<RootNamespace>MongoDB.Extensions.Migration</RootNamespace>
<PackageId>MongoDB.Extensions.Migration</PackageId>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.15.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "$set" : { "Name" : "Spain" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$set" : {
"_id" : CSUUID("44752191-e10b-435a-a0e9-62e7f13d41cd")
}
}
10 changes: 8 additions & 2 deletions src/Prime.Extensions/Prime.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="System.Text.Json" Version="6.0.6" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
Expand Down
24 changes: 15 additions & 9 deletions src/Session.Tests/MongoServerExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
using Snapshooter.Xunit;
using Squadron;
using Xunit;
using Xunit.Abstractions;

namespace MongoDB.Extensions.Session.Tests
{
public class MongoServerExtensionsTests : IClassFixture<MongoResource>
{
private readonly IMongoClient _mongoClient;

public MongoServerExtensionsTests(MongoResource mongoResource)
{
_mongoClient = mongoResource.Client;
Expand All @@ -39,6 +40,8 @@ public async Task GiveSession_WhenRefresh_ThanLastUseIsUpdated()
{
// Arrange
IClientSessionHandle session = await _mongoClient.StartSessionAsync();
Guid sessionId = session.GetSessionId();

List<ServerSession> serverSessionsFirst = await GetServerSessions();

// Act
Expand All @@ -48,17 +51,19 @@ public async Task GiveSession_WhenRefresh_ThanLastUseIsUpdated()

// Assert
ServerSession sessionFirstUse = serverSessionsFirst
.First(s => s.Id == session.GetSessionId());
.First(s => s.Id == sessionId);
ServerSession sessionSecondUse = serverSessionsSecond
.First(s => s.Id == session.GetSessionId());
.First(s => s.Id == sessionId);
Assert.True(sessionSecondUse.LastUse > sessionFirstUse.LastUse);
}

[Fact]
public async Task GiveSession_WhenNoRefresh_ThanLastUseIsSame()
{
{
// Arrange
IClientSessionHandle session = await _mongoClient.StartSessionAsync();
Guid sessionId = session.GetSessionId();

List<ServerSession> serverSessionsFirst = await GetServerSessions();

// Act
Expand All @@ -67,18 +72,19 @@ public async Task GiveSession_WhenNoRefresh_ThanLastUseIsSame()

// Assert
ServerSession sessionFirstUse = serverSessionsFirst
.First(s => s.Id == session.GetSessionId());
.First(s => s.Id == sessionId);
ServerSession sessionSecondUse = serverSessionsSecond
.First(s => s.Id == session.GetSessionId());
Assert.True(sessionSecondUse.LastUse == sessionFirstUse.LastUse);
.First(s => s.Id == sessionId);

Assert.Equal(sessionSecondUse.LastUse, sessionFirstUse.LastUse);
}

private Task<List<ServerSession>> GetServerSessions()
private async Task<List<ServerSession>> GetServerSessions()
{
var pipeline = PipelineDefinition<NoPipelineInput, ServerSession>
.Create("{ $listLocalSessions: { allUsers: true } }");

return _mongoClient
return await _mongoClient
.GetDatabase("config")
.WithReadConcern(ReadConcern.Local)
.Aggregate(pipeline)
Expand Down
2 changes: 1 addition & 1 deletion src/Session/Session.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion src/TestProject.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(TestProjectTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
45 changes: 45 additions & 0 deletions src/Transactions/MongoTransactionDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,51 @@ public MongoTransactionDatabase(IMongoDatabase database)
.CreateViewAsync(session, viewName, viewOn, pipeline, options, cancellationToken);
}

public void DropCollection(
string name,
DropCollectionOptions options,
CancellationToken cancellationToken = default)
{
if (TryGetSession(out IClientSessionHandle? session))
{
_database.DropCollection(session, name, options, cancellationToken);
return;
}

_database.DropCollection(name, options, cancellationToken);
}

public void DropCollection(
IClientSessionHandle session,
string name,
DropCollectionOptions options,
CancellationToken cancellationToken = default)
{
_database.DropCollectionAsync(session, name, options, cancellationToken);
}

public Task DropCollectionAsync(
string name,
DropCollectionOptions options,
CancellationToken cancellationToken = default)
{
if (TryGetSession(out IClientSessionHandle? session))
{
return _database.DropCollectionAsync(session, name, options, cancellationToken);
}

return _database.DropCollectionAsync(name, options, cancellationToken);
}

public Task DropCollectionAsync(
IClientSessionHandle session,
string name,
DropCollectionOptions options,
CancellationToken cancellationToken = default)
{
return _database.DropCollectionAsync(session, name, options, cancellationToken);
}

public void DropCollection(string name, CancellationToken cancellationToken = default)
{
if (TryGetSession(out IClientSessionHandle? session))
Expand Down
2 changes: 1 addition & 1 deletion src/Transactions/Transactions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
</ItemGroup>

</Project>

0 comments on commit d2c7b75

Please sign in to comment.