Skip to content

Commit

Permalink
Upgrade to .NET 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Nov 20, 2024
1 parent b9d98d4 commit 7ce8a9a
Show file tree
Hide file tree
Showing 48 changed files with 116 additions and 117 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore
Expand All @@ -57,7 +57,7 @@ jobs:
# uses: actions/setup-dotnet@main
# with:
# dotnet-version: |
# 8.0.x
# 9.0.x

# - name: Install dependencies
# run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore

Expand All @@ -32,7 +32,7 @@ jobs:
# uses: actions/setup-dotnet@main
# with:
# dotnet-version: |
# 8.0.x
# 9.0.x
# - name: Install dependencies
# run: dotnet restore

Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: |
8.0.x
9.0.x
- name: Restore ${{ matrix.project }} dependencies
run: dotnet restore ./src/${{ matrix.project }}/${{ matrix.project }}.csproj
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<PropertyGroup>
<CompatibilityTargetFrameworks>netstandard2.0</CompatibilityTargetFrameworks>
<DefaultTargetFrameworks>net7.0;net8.0;</DefaultTargetFrameworks>
<DefaultTargetFrameworks>net8.0;net9.0</DefaultTargetFrameworks>
<LangVersion>preview</LangVersion>
</PropertyGroup>

Expand Down
44 changes: 22 additions & 22 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AspNetCore.HealthChecks.CosmosDb" Version="8.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.CosmosDb" Version="8.0.1" />
<PackageVersion Include="Bogus" Version="35.6.1" />
<PackageVersion Include="CorrelationId" Version="3.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
<PackageVersion Include="IEvangelist.Azure.CosmosRepository" Version="8.1.7" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.38.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.46.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Mumby0168.CleanArchitecture.Exceptions.AspNetCore" Version="1.1.0" />
<PackageVersion Include="Mumby0168.CleanArchitecture.Exceptions" Version="1.0.0" />
<PackageVersion Include="Polly" Version="8.3.0" />
<PackageVersion Include="Scrutor" Version="5.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageVersion Include="Polly" Version="8.5.0" />
<PackageVersion Include="Scrutor" Version="5.0.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.0.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Net.Http.Json" Version="8.0.1" />
<PackageVersion Include="System.Net.Http.Json" Version="9.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>373fc06c-c3e7-4ecb-bf30-88a8ae4eb700</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>55a00f1c-8604-4ac2-adf3-dd3127af43bc</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>ce605ed2-3eba-45c1-8970-76b34c1c2837</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>66ceb007-2b64-4ecc-8234-8eb82effee6b</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ await repository.CreateAsync(

public class ExampleModel : Item
{
public string Category { get; set; }
public required string Category { get; set; }
}

public class ExampleSpecification : DefaultSpecification<ExampleModel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>fd4da918-55af-4010-9ba0-e75f0e0dc917</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<UserSecretsId>9c9f04ba-0288-4b94-a15e-c669da85dfad</UserSecretsId>
</PropertyGroup>

Expand Down
10 changes: 5 additions & 5 deletions samples/Microsoft.Azure.CosmosRepository/ServiceTier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static async Task RoundtripCrudOpsOnPeopleRepositoryAsync(IRepository<Person> re

// Creating...
Console.WriteLine("[Person] Repository creating...");
_ = await repository.CreateAsync(new[] { maryShaw, calvinWeatherfield });
_ = await repository.CreateAsync([maryShaw, calvinWeatherfield]);

// Reading...
Person mary = await repository.GetAsync(maryShaw.Id, maryShaw.SyntheticPartitionKey);
Expand Down Expand Up @@ -117,7 +117,7 @@ static async Task VerifyUpdates(IRepository<Widget> repo)

// Creating...
Console.WriteLine("[Widget] Repository creating...");
_ = await repository.CreateAsync(new[] { widget1, widget2 });
_ = await repository.CreateAsync([widget1, widget2]);

// Reading...
Widget contraption = await repository.GetAsync(widget1.Id);
Expand Down Expand Up @@ -208,9 +208,9 @@ static async Task ServiceExampleAsync(IExampleService service)

// Deleting...
Console.WriteLine("[Person] Service deleting...");
await Task.WhenAll(new[]
{
await Task.WhenAll(
[
service.DeletePersonAsync(james).AsTask(),
service.DeletePersonAsync(adele).AsTask()
});
]);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="IEvangelist.Azure.CosmosRepository" />
<ProjectReference Include="..\..\..\src\Microsoft.Azure.CosmosRepository\Microsoft.Azure.CosmosRepository.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task Post_Always_Creates_A_Language()
Id = string.Empty,
Name = "C#",
Description = "A language created by Microsoft.",
Aliases = new[] { "C#", ".NET" },
Aliases = ["C#", ".NET"],
PrimaryStyle = ProgrammingStyle.ObjectOriented,
InitialReleaseDate = new DateTime(2001, 10, 25)
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<UserSecretsId>faa0315d-a570-4d95-9c36-14570d154189</UserSecretsId>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ICosmosEventSourcingBuilder AddDomainEventTypes(
.Where(type => typeof(IDomainEvent).IsAssignableFrom(type)))
.ToList();

types.ForEach(t => DomainEventConverter.ConvertableTypes.Add(t));
types.ForEach(t => DomainEventConverter.ConvertibleTypes.Add(t));

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,33 @@ namespace Microsoft.Azure.CosmosEventSourcing.Converters;

internal class DomainEventConverter : JsonConverter
{
public static HashSet<Type> ConvertableTypes { get; } = [];
public static HashSet<Type> ConvertibleTypes { get; } = [];

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) =>
serializer.Serialize(writer, value, value.GetType());
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) =>
serializer.Serialize(writer, value, objectType: value?.GetType() ?? throw new ArgumentNullException(nameof(value)));

public override object ReadJson(
public override object? ReadJson(
JsonReader reader,
Type objectType,
object existingValue,
object? existingValue,
JsonSerializer serializer)
{
try
{
var j = JToken.ReadFrom(reader);
var type = j["eventName"]?.ToString();
type ??= j["EventName"]?.ToString();
Type? payloadType = ConvertableTypes.FirstOrDefault(x => x.Name == type);
Type? payloadType = ConvertibleTypes.FirstOrDefault(x => x.Name == type);

if (payloadType is null)
return payloadType switch
{
return new NonDeserializableEvent
null => new NonDeserializableEvent
{
Name = type ?? "not-defined",
Payload = j.ToObject<JObject>()
};
}

return j.ToObject(payloadType);
Payload = j.ToObject<JObject>() ?? []
},
_ => j.ToObject(payloadType)
};
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IServiceCollection AddCosmosEventSourcing(
Action<ICosmosEventSourcingBuilder> eventSourcingBuilder)
{
DefaultCosmosEventSourcingBuilder builder = new(services);
DomainEventConverter.ConvertableTypes.Add(typeof(AtomicEvent));
DomainEventConverter.ConvertibleTypes.Add(typeof(AtomicEvent));
eventSourcingBuilder.Invoke(builder);
services.AddScoped<IContextService, DefaultContextService>();
services.AddScoped(typeof(IEventStore<>), typeof(DefaultEventStore<>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ await Task.WhenAll(handlers.Select(handler =>
try
{
var result = handlerType.GetMethod("HandleAsync")?
.Invoke(handler, new object[] { eventItem.DomainEvent, eventItem, cancellationToken });
.Invoke(handler, [eventItem.DomainEvent, eventItem, cancellationToken]);

if (result is ValueTask valueTask)
{
Expand Down
Loading

0 comments on commit 7ce8a9a

Please sign in to comment.