Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#149) Update all packages to 8.x latest. #151

Merged
merged 15 commits into from
Nov 15, 2024
Merged
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
2 changes: 1 addition & 1 deletion Datasync.Toolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D59F1489-5D74-4F52-B78B-88037EAB2838}"
ProjectSection(SolutionItems) = preProject
tests\Directory.Build.props = tests\Directory.Build.props
tests\EFCore.Packages.props = tests\EFCore.Packages.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Server.Abstractions", "src\CommunityToolkit.Datasync.Server.Abstractions\CommunityToolkit.Datasync.Server.Abstractions.csproj", "{852F8266-603E-4FC6-A5CB-E492E747924F}"
Expand Down Expand Up @@ -44,6 +43,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.T
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{2D2A6EFC-015D-4258-96D4-24C78F8C59F9}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
.github\workflows\SignedPackageFileList.txt = .github\workflows\SignedPackageFileList.txt
.github\workflows\SignedTemplateFileList.txt = .github\workflows\SignedTemplateFileList.txt
EndProjectSection
Expand Down
51 changes: 27 additions & 24 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,37 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="AutoMapper" Version="12.0.1" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentAssertions.Web" Version="1.2.5" />
<PackageVersion Include="LiteDB" Version="5.0.17" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="8.2.5" />
<PackageVersion Include="Microsoft.Azure.Core.Spatial" Version="1.1.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Cosmos" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="Azure.Identity" Version="1.13.1" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="FluentAssertions.Web" Version="1.5.0" />
<PackageVersion Include="LiteDB" Version="5.0.21" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="9.1.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Cosmos" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" 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.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.Spatial" Version="7.20.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="14.0.8" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.1" />
<PackageVersion Include="Microsoft.Spatial" Version="8.2.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="14.1.0" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.0.0" />
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.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="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="Ulid" Version="1.3.4" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>The client capabilities for developing applications using the Datasync Toolkit.</Description>
</PropertyGroup>
Expand All @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="Microsoft.Extensions.Http" />
<PackageReference Include="Microsoft.Azure.Core.Spatial" />
<PackageReference Include="System.Threading.Tasks.Dataflow" />
<PackageReference Include="Microsoft.Spatial" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace CommunityToolkit.Datasync.Client;
/// <typeparam name="T"></typeparam>
public class ConcurrentObservableCollection<T> : ObservableCollection<T>
{
private readonly SynchronizationContext context = SynchronizationContext.Current!;
private readonly SynchronizationContext? currentContext = SynchronizationContext.Current;
private bool suppressNotification = false;

/// <summary>
Expand Down Expand Up @@ -151,31 +151,30 @@ public bool ReplaceIf(Func<T, bool> match, T replacement)
/// </summary>
/// <param name="e">The event arguments</param>
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
=> DispatchCallback(new SynchronizationContextAdapter(this.context), RaiseCollectionChanged, e);
{
if (this.currentContext is null || SynchronizationContext.Current == this.currentContext)
{
RaiseCollectionChanged(e);
}
else
{
this.currentContext.Send(RaiseCollectionChanged, e);
}
}

/// <summary>
/// Event trigger to indicate that a property has changed in a thread-safe way.
/// </summary>
/// <param name="e">The event arguments</param>
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
=> DispatchCallback(new SynchronizationContextAdapter(this.context), RaisePropertyChanged, e);

/// <summary>
/// Dispatches the callback to the synchronization context. If the synchronization context is
/// the current one, we can avoid a dispatch and just call the callback directly.
/// </summary>
/// <param name="context">The context to send the request to.</param>
/// <param name="callback">The callback method.</param>
/// <param name="param">The parameter for the callback method.</param>
internal static void DispatchCallback(ISynchronizationContext context, SendOrPostCallback callback, object? param)
{
if (context.IsCurrentContext())
if (this.currentContext is null || SynchronizationContext.Current == this.currentContext)
{
callback(param);
RaisePropertyChanged(e);
}
else
{
context.Send(callback, param);
this.currentContext.Send(RaisePropertyChanged, e);
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Azure.Core.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -58,7 +57,7 @@ public static string Serialize(object obj, Type objType)
new DateTimeOffsetConverter(),
new DateTimeConverter(),
new TimeOnlyConverter(),
new MicrosoftSpatialGeoJsonConverter()
new SpatialGeoJsonConverter()
},
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json;

namespace CommunityToolkit.Datasync.Client.Serialization;

/// <summary>
/// Extension methods for System.Text.Json.
/// </summary>
internal static class JsonExtensions
{
/// <summary>
/// Asserts that the current token of the <see cref="Utf8JsonReader"/> matches the <paramref name="expectedTokenType"/>.
/// </summary>
/// <param name="reader">The <see cref="Utf8JsonReader"/> to assert.</param>
/// <param name="expectedTokenType">The expected <see cref="JsonTokenType"/> of the current token.</param>
/// <exception cref="JsonException">The current token did not match the <paramref name="expectedTokenType"/>.</exception>
public static void Expect(in this Utf8JsonReader reader, JsonTokenType expectedTokenType)
{
if (reader.TokenType != expectedTokenType)
{
throw new JsonException($"Deserialization failed. Expected token: '{expectedTokenType}'.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Spatial;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace CommunityToolkit.Datasync.Client.Serialization;

/// <summary>
/// Converters between Microsoft.Spatial types and GeoJSON
/// </summary>
/// <remarks>
/// Only handles GeographyPoint at this time.
/// </remarks>
/// <see href="https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.1.0/sdk/core/Microsoft.Azure.Core.Spatial/src/Serialization" />
public class SpatialGeoJsonConverter : JsonConverter<object>
{
private const string CoordinatesPropertyName = "coordinates";
private const string PointTypeName = "Point";
private const string TypePropertyName = "type";

private static readonly JsonEncodedText s_CoordinatesPropertyNameBytes = JsonEncodedText.Encode(CoordinatesPropertyName);
private static readonly JsonEncodedText s_TypePropertyNameBytes = JsonEncodedText.Encode(TypePropertyName);

/// <inheritdoc/>
public override bool CanConvert(Type typeToConvert) =>
typeof(GeographyPoint).IsAssignableFrom(typeToConvert);

/// <inheritdoc/>
public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
{
return null;
}

string? type = default;
double? longitude = default;
double? latitude = default;

reader.Expect(JsonTokenType.StartObject);
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
{
reader.Expect(JsonTokenType.PropertyName);
string? propertyName = reader.GetString();

_ = reader.Read();
if (string.Equals(TypePropertyName, propertyName, StringComparison.Ordinal))
{
reader.Expect(JsonTokenType.String);
type = reader.GetString();
}
else if (string.Equals(CoordinatesPropertyName, propertyName, StringComparison.Ordinal))
{
reader.Expect(JsonTokenType.StartArray);

// Longitude
_ = reader.Read();
reader.Expect(JsonTokenType.Number);
longitude = reader.GetDouble();

// Latitude
_ = reader.Read();
reader.Expect(JsonTokenType.Number);
latitude = reader.GetDouble();

// Skip the rest.
do
{
_ = reader.Read();
} while (reader.TokenType != JsonTokenType.EndArray);
}
else
{
reader.Skip();
}
}

if (!string.Equals(PointTypeName, type, StringComparison.Ordinal))
{
throw new JsonException($"Deserialization of {nameof(GeographyPoint)} failed. Expected geographic type: '{PointTypeName}'.");
}

if (!longitude.HasValue || !latitude.HasValue)
{
throw new JsonException($"Deserialization of {nameof(GeographyPoint)} failed. Expected both longitude and latitude.");
}

return GeographyPoint.Create(latitude.Value, longitude.Value);
}

/// <inheritdoc/>
public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)
{
if (value is GeographyPoint point)
{
writer.WriteStartObject();
writer.WriteString(s_TypePropertyNameBytes, PointTypeName);
writer.WriteStartArray(s_CoordinatesPropertyNameBytes);
writer.WriteNumberValue(point.Longitude);
writer.WriteNumberValue(point.Latitude);
writer.WriteEndArray();
writer.WriteEndObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<PropertyGroup>
<Description>Abstractions for developing server-side applications using the Datasync Toolkit.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Core.Spatial" />
<PackageReference Include="Microsoft.Spatial" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json;

namespace CommunityToolkit.Datasync.Server.Abstractions.Json;

/// <summary>
/// Extension methods for System.Text.Json.
/// </summary>
internal static class JsonExtensions
{
/// <summary>
/// Asserts that the current token of the <see cref="Utf8JsonReader"/> matches the <paramref name="expectedTokenType"/>.
/// </summary>
/// <param name="reader">The <see cref="Utf8JsonReader"/> to assert.</param>
/// <param name="expectedTokenType">The expected <see cref="JsonTokenType"/> of the current token.</param>
/// <exception cref="JsonException">The current token did not match the <paramref name="expectedTokenType"/>.</exception>
public static void Expect(in this Utf8JsonReader reader, JsonTokenType expectedTokenType)
{
if (reader.TokenType != expectedTokenType)
{
throw new JsonException($"Deserialization failed. Expected token: '{expectedTokenType}'.");
}
}
}
Loading
Loading