Skip to content

Commit 83836e9

Browse files
author
Bart Koelman
committed
Reformat solution
1 parent c40ae47 commit 83836e9

File tree

108 files changed

+3423
-3657
lines changed

Some content is hidden

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

108 files changed

+3423
-3657
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using JsonApiDotNetCore.OpenApi.Client;
22
using Newtonsoft.Json;
33

4-
namespace JsonApiDotNetCoreExampleClient
4+
namespace JsonApiDotNetCoreExampleClient;
5+
6+
public partial class ExampleApiClient : JsonApiClient
57
{
6-
public partial class ExampleApiClient : JsonApiClient
8+
partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings)
79
{
8-
partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings)
9-
{
10-
SetSerializerSettingsForJsonApi(settings);
10+
SetSerializerSettingsForJsonApi(settings);
1111

12-
settings.Formatting = Formatting.Indented;
13-
}
12+
settings.Formatting = Formatting.Indented;
1413
}
1514
}
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1-
using System;
2-
using System.Net.Http;
3-
using System.Threading.Tasks;
1+
namespace JsonApiDotNetCoreExampleClient;
42

5-
namespace JsonApiDotNetCoreExampleClient
3+
internal static class Program
64
{
7-
internal static class Program
8-
{
9-
private const string BaseUrl = "http://localhost:14140";
10-
11-
private static async Task Main()
12-
{
13-
using var httpClient = new HttpClient();
5+
private const string BaseUrl = "http://localhost:14140";
146

15-
ExampleApiClient exampleApiClient = new(BaseUrl, httpClient);
7+
private static async Task Main()
8+
{
9+
using var httpClient = new HttpClient();
1610

17-
try
18-
{
19-
const int nonExistingId = int.MaxValue;
20-
await exampleApiClient.Delete_personAsync(nonExistingId);
21-
}
22-
catch (ApiException exception)
23-
{
24-
Console.WriteLine(exception.Response);
25-
}
11+
ExampleApiClient exampleApiClient = new(BaseUrl, httpClient);
2612

27-
Console.WriteLine("Press any key to close.");
28-
Console.ReadKey();
13+
try
14+
{
15+
const int nonExistingId = int.MaxValue;
16+
await exampleApiClient.Delete_personAsync(nonExistingId);
17+
}
18+
catch (ApiException exception)
19+
{
20+
Console.WriteLine(exception.Response);
2921
}
22+
23+
Console.WriteLine("Press any key to close.");
24+
Console.ReadKey();
3025
}
3126
}
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
using System;
21
using JetBrains.Annotations;
32
using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
43

54
#pragma warning disable AV1008 // Class should not be static
65

7-
namespace JsonApiDotNetCore.OpenApi.Client
6+
namespace JsonApiDotNetCore.OpenApi.Client;
7+
8+
internal static class ArgumentGuard
89
{
9-
internal static class ArgumentGuard
10+
[AssertionMethod]
11+
public static void NotNull<T>([NoEnumeration] [SysNotNull] T? value, [InvokerParameterName] string name)
12+
where T : class
1013
{
11-
[AssertionMethod]
12-
public static void NotNull<T>([NoEnumeration] [SysNotNull] T? value, [InvokerParameterName] string name)
13-
where T : class
14+
if (value is null)
1415
{
15-
if (value is null)
16-
{
17-
throw new ArgumentNullException(name);
18-
}
16+
throw new ArgumentNullException(name);
1917
}
2018
}
2119
}
Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
using System;
21
using System.Linq.Expressions;
32

4-
namespace JsonApiDotNetCore.OpenApi.Client
3+
namespace JsonApiDotNetCore.OpenApi.Client;
4+
5+
public interface IJsonApiClient
56
{
6-
public interface IJsonApiClient
7-
{
8-
/// <summary>
9-
/// Ensures correct serialization of attributes in a POST/PATCH Resource request body. In JSON:API, an omitted attribute indicates to ignore it, while an
10-
/// attribute that is set to "null" means to clear it. This poses a problem because the serializer cannot distinguish between "you have explicitly set
11-
/// this .NET property to null" vs "you didn't touch it, so it is null by default" when converting an instance to JSON. Therefore, calling this method
12-
/// treats all attributes that contain their default value (<c>null</c> for reference types, <c>0</c> for integers, <c>false</c> for booleans, etc) as
13-
/// omitted unless explicitly listed to include them using <paramref name="alwaysIncludedAttributeSelectors" />.
14-
/// </summary>
15-
/// <param name="requestDocument">
16-
/// The request document instance for which this registration applies.
17-
/// </param>
18-
/// <param name="alwaysIncludedAttributeSelectors">
19-
/// Optional. A list of expressions to indicate which properties to unconditionally include in the JSON request body. For example:
20-
/// <code><![CDATA[
21-
/// video => video.Title, video => video.Summary
22-
/// ]]></code>
23-
/// </param>
24-
/// <typeparam name="TRequestDocument">
25-
/// The type of the request document.
26-
/// </typeparam>
27-
/// <typeparam name="TAttributesObject">
28-
/// The type of the attributes object inside <typeparamref name="TRequestDocument" />.
29-
/// </typeparam>
30-
/// <returns>
31-
/// An <see cref="IDisposable" /> to clear the current registration. For efficient memory usage, it is recommended to wrap calls to this method in a
32-
/// <c>using</c> statement, so the registrations are cleaned up after executing the request.
33-
/// </returns>
34-
IDisposable RegisterAttributesForRequestDocument<TRequestDocument, TAttributesObject>(TRequestDocument requestDocument,
35-
params Expression<Func<TAttributesObject, object?>>[] alwaysIncludedAttributeSelectors)
36-
where TRequestDocument : class;
37-
}
7+
/// <summary>
8+
/// Ensures correct serialization of attributes in a POST/PATCH Resource request body. In JSON:API, an omitted attribute indicates to ignore it, while an
9+
/// attribute that is set to "null" means to clear it. This poses a problem because the serializer cannot distinguish between "you have explicitly set
10+
/// this .NET property to null" vs "you didn't touch it, so it is null by default" when converting an instance to JSON. Therefore, calling this method
11+
/// treats all attributes that contain their default value (<c>null</c> for reference types, <c>0</c> for integers, <c>false</c> for booleans, etc) as
12+
/// omitted unless explicitly listed to include them using <paramref name="alwaysIncludedAttributeSelectors" />.
13+
/// </summary>
14+
/// <param name="requestDocument">
15+
/// The request document instance for which this registration applies.
16+
/// </param>
17+
/// <param name="alwaysIncludedAttributeSelectors">
18+
/// Optional. A list of expressions to indicate which properties to unconditionally include in the JSON request body. For example:
19+
/// <code><![CDATA[
20+
/// video => video.Title, video => video.Summary
21+
/// ]]></code>
22+
/// </param>
23+
/// <typeparam name="TRequestDocument">
24+
/// The type of the request document.
25+
/// </typeparam>
26+
/// <typeparam name="TAttributesObject">
27+
/// The type of the attributes object inside <typeparamref name="TRequestDocument" />.
28+
/// </typeparam>
29+
/// <returns>
30+
/// An <see cref="IDisposable" /> to clear the current registration. For efficient memory usage, it is recommended to wrap calls to this method in a
31+
/// <c>using</c> statement, so the registrations are cleaned up after executing the request.
32+
/// </returns>
33+
IDisposable RegisterAttributesForRequestDocument<TRequestDocument, TAttributesObject>(TRequestDocument requestDocument,
34+
params Expression<Func<TAttributesObject, object?>>[] alwaysIncludedAttributeSelectors)
35+
where TRequestDocument : class;
3836
}

0 commit comments

Comments
 (0)