Skip to content

Commit d88ca21

Browse files
authored
(#35) Completed service client with OData LINQ queries. (#54)
* Complete service client for talking to the datasync service. * Complete LINQ query coverage. * Tests with 100% coverage.
1 parent 9d6e6fb commit d88ca21

File tree

152 files changed

+11331
-4207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+11331
-4207
lines changed

Datasync.Toolkit.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.S
2424
EndProject
2525
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Server.LiteDb", "src\CommunityToolkit.Datasync.Server.LiteDb\CommunityToolkit.Datasync.Server.LiteDb.csproj", "{66A40624-ADF3-4469-A1D5-E5BD854CFA94}"
2626
EndProject
27-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Common.Test", "tests\CommunityToolkit.Datasync.Common.Test\CommunityToolkit.Datasync.Common.Test.csproj", "{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641}"
28-
EndProject
2927
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Server.Automapper.Test", "tests\CommunityToolkit.Datasync.Server.Automapper.Test\CommunityToolkit.Datasync.Server.Automapper.Test.csproj", "{E322C30C-F40C-4594-86ED-DAA90E2F5611}"
3028
EndProject
3129
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Server.EntityFrameworkCore.Test", "tests\CommunityToolkit.Datasync.Server.EntityFrameworkCore.Test\CommunityToolkit.Datasync.Server.EntityFrameworkCore.Test.csproj", "{B616A68F-F8B6-49C3-AB14-4718F09F2082}"
@@ -44,8 +42,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.T
4442
EndProject
4543
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.TestCommon", "tests\CommunityToolkit.Datasync.TestCommon\CommunityToolkit.Datasync.TestCommon.csproj", "{AC514FCF-C0D8-438F-A12C-A259CEB7B43D}"
4644
EndProject
47-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Common", "src\CommunityToolkit.Datasync.Common\CommunityToolkit.Datasync.Common.csproj", "{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7}"
48-
EndProject
4945
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{2D2A6EFC-015D-4258-96D4-24C78F8C59F9}"
5046
ProjectSection(SolutionItems) = preProject
5147
.github\workflows\SignedPackageFileList.txt = .github\workflows\SignedPackageFileList.txt
@@ -90,10 +86,6 @@ Global
9086
{66A40624-ADF3-4469-A1D5-E5BD854CFA94}.Debug|Any CPU.Build.0 = Debug|Any CPU
9187
{66A40624-ADF3-4469-A1D5-E5BD854CFA94}.Release|Any CPU.ActiveCfg = Release|Any CPU
9288
{66A40624-ADF3-4469-A1D5-E5BD854CFA94}.Release|Any CPU.Build.0 = Release|Any CPU
93-
{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94-
{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641}.Debug|Any CPU.Build.0 = Debug|Any CPU
95-
{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641}.Release|Any CPU.ActiveCfg = Release|Any CPU
96-
{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641}.Release|Any CPU.Build.0 = Release|Any CPU
9789
{E322C30C-F40C-4594-86ED-DAA90E2F5611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
9890
{E322C30C-F40C-4594-86ED-DAA90E2F5611}.Debug|Any CPU.Build.0 = Debug|Any CPU
9991
{E322C30C-F40C-4594-86ED-DAA90E2F5611}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -130,10 +122,6 @@ Global
130122
{AC514FCF-C0D8-438F-A12C-A259CEB7B43D}.Debug|Any CPU.Build.0 = Debug|Any CPU
131123
{AC514FCF-C0D8-438F-A12C-A259CEB7B43D}.Release|Any CPU.ActiveCfg = Release|Any CPU
132124
{AC514FCF-C0D8-438F-A12C-A259CEB7B43D}.Release|Any CPU.Build.0 = Release|Any CPU
133-
{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
134-
{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
135-
{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
136-
{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7}.Release|Any CPU.Build.0 = Release|Any CPU
137125
{C56A5630-03D7-43EF-BC09-69CA97152CFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
138126
{C56A5630-03D7-43EF-BC09-69CA97152CFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
139127
{C56A5630-03D7-43EF-BC09-69CA97152CFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -168,7 +156,6 @@ Global
168156
{1C3C2B80-ECE3-4442-8183-C2AD7F735D8E} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
169157
{343D137B-FE42-4D56-85E8-AAEA2486CBDB} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
170158
{66A40624-ADF3-4469-A1D5-E5BD854CFA94} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
171-
{89BB94FD-0B89-4AE9-B2CF-9FB891E0B641} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
172159
{E322C30C-F40C-4594-86ED-DAA90E2F5611} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
173160
{B616A68F-F8B6-49C3-AB14-4718F09F2082} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
174161
{8255CE7F-B549-4477-A0AC-E66B3A9C12C4} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
@@ -178,7 +165,6 @@ Global
178165
{0F17CC55-9DC8-4CCA-9C64-D1EFB6134D32} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
179166
{1A3EE020-7299-4F00-A11F-06DD241EC6EA} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
180167
{AC514FCF-C0D8-438F-A12C-A259CEB7B43D} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
181-
{E1AC26CF-5C5C-400C-97F6-416D6FCF5BC7} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
182168
{C56A5630-03D7-43EF-BC09-69CA97152CFC} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
183169
{983FB40E-BA00-4055-9A8A-24E1A351FB5B} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
184170
{F578EC54-454F-4114-AC37-C83A7831E783} = {D59F1489-5D74-4F52-B78B-88037EAB2838}

src/CommunityToolkit.Datasync.Client/CommunityToolkit.Datasync.Client.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
<ItemGroup>
77
<InternalsVisibleTo Include="CommunityToolkit.Datasync.Client.Test" />
88
</ItemGroup>
9-
10-
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
12-
</ItemGroup>
139

1410
<ItemGroup>
15-
<ProjectReference Include="..\CommunityToolkit.Datasync.Common\CommunityToolkit.Datasync.Common.csproj" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
12+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
13+
<PackageReference Include="Microsoft.Azure.Core.Spatial" Version="1.1.0" />
1614
</ItemGroup>
17-
1815
</Project>

src/CommunityToolkit.Datasync.Client/DatasyncClient.cs

Lines changed: 0 additions & 133 deletions
This file was deleted.

src/CommunityToolkit.Datasync.Client/DatasyncClientDefaults.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/CommunityToolkit.Datasync.Client/DatasyncClientOptions.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/CommunityToolkit.Datasync.Client/Exceptions/ConflictException.cs

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,28 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System.Diagnostics.CodeAnalysis;
6-
using System.Text.Json;
5+
using CommunityToolkit.Datasync.Client.Service;
76

87
namespace CommunityToolkit.Datasync.Client;
98

109
/// <summary>
11-
/// An exception used by the Datasync client library to report server conflict errors.
10+
/// An exception that represents a conflict between the client and server.
1211
/// </summary>
13-
/// <typeparam name="T">The type of entity in conflict</typeparam>
14-
public class ConflictException<T> : DatasyncHttpException where T : notnull
12+
/// <typeparam name="TEntity">The type of entity being transmitted to the server.</typeparam>
13+
/// <remarks>
14+
/// Creates a new <see cref="ConflictException{TEntity}"/> based on a client entity and server response.
15+
/// </remarks>
16+
/// <param name="clientEntity">The client entity that was sent to the server.</param>
17+
/// <param name="serviceResponse">The response from the server.</param>
18+
public class ConflictException<TEntity>(TEntity? clientEntity, ServiceResponse<TEntity> serviceResponse) : DatasyncHttpException(serviceResponse)
1519
{
16-
/// <inheritdoc />
17-
public ConflictException(string? message) : base(message)
18-
{
19-
}
20-
21-
/// <inheritdoc />
22-
[ExcludeFromCodeCoverage(Justification = "Standard exception constructor")]
23-
public ConflictException(string? message, Exception? innerException) : base(message, innerException)
24-
{
25-
}
26-
2720
/// <summary>
28-
/// The parsed server-side entity (or null).
21+
/// The client entity that was sent to the server.
2922
/// </summary>
30-
public T? ServerEntity { get; set; } = default;
23+
public TEntity? ClientEntity { get; } = clientEntity;
3124

3225
/// <summary>
33-
/// Creates a new <see cref="ConflictException{T}"/> for the response.
26+
/// The entity that is stored on the server.
3427
/// </summary>
35-
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> that is creating the exception.</param>
36-
/// <param name="serializerOptions">The JSON serializer options to use for deserializing content.</param>
37-
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
38-
/// <returns></returns>
39-
public static async Task<ConflictException<T>> CreateAsync(HttpResponseMessage responseMessage, JsonSerializerOptions serializerOptions, CancellationToken cancellationToken = default)
40-
{
41-
try
42-
{
43-
string mediaType = responseMessage.Content.Headers.ContentType?.MediaType ?? string.Empty;
44-
string content = await responseMessage.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
45-
return new ConflictException<T>(responseMessage.ReasonPhrase)
46-
{
47-
StatusCode = responseMessage.StatusCode,
48-
ContentType = mediaType,
49-
Payload = content,
50-
ServerEntity = JsonSerializer.Deserialize<T>(content, serializerOptions)
51-
};
52-
}
53-
catch (JsonException ex)
54-
{
55-
throw new DatasyncException("Invalid JSON content received from server", ex);
56-
}
57-
}
28+
public TEntity? ServerEntity { get; } = serviceResponse.Value;
5829
}

0 commit comments

Comments
 (0)