Skip to content

Commit 9b88b0a

Browse files
chore(client): update formatting
1 parent 436c50d commit 9b88b0a

File tree

7 files changed

+54
-31
lines changed

7 files changed

+54
-31
lines changed

src/Sentdm/Core/ApiEnum.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ namespace Sentdm.Core;
1111
///
1212
/// <para>In most cases you don't have to worry about this type and can rely on its implicit operators to
1313
/// wrap and unwrap enum values.</para>
14-
///
15-
/// <param name="Json">
16-
/// Returns this instance's raw value.
17-
///
18-
/// <para>This is usually only useful if this instance was deserialized from data that doesn't match the
19-
/// expected type (<typeparamref name="TRaw"/>), and you want to know that value. For example, if the
20-
/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is
21-
/// unaware of.</para>
22-
/// </param>
2314
/// </summary>
24-
public record class ApiEnum<TRaw, TEnum>(JsonElement Json)
15+
public record class ApiEnum<TRaw, TEnum>
2516
where TEnum : struct, Enum
2617
{
18+
/// <summary>
19+
/// Returns this instance's raw value.
20+
///
21+
/// <para>This is usually only useful if this instance was deserialized from data that doesn't match the
22+
/// expected type (<typeparamref name="TRaw"/>), and you want to know that value. For example, if the
23+
/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is
24+
/// unaware of.
25+
/// </para>
26+
/// </summary>
27+
public JsonElement Json;
28+
29+
public ApiEnum(JsonElement json)
30+
{
31+
Json = json;
32+
}
33+
2734
/// <summary>
2835
/// Returns this instance's raw <typeparamref name="TRaw"/> value.
2936
///

src/Sentdm/Core/ClientOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public string BaseUrl
7171
/// <para>Defaults to 2 when null. Set to 0 to
7272
/// disable retries, which also ignores API instructions to retry.</para>
7373
/// </summary>
74-
public int? MaxRetries { get; set; }
74+
public int? MaxRetries { get; set; } = null;
7575

7676
/// <summary>
7777
/// Sets the maximum time allowed for a complete HTTP call, not including retries.
@@ -81,7 +81,7 @@ public string BaseUrl
8181
///
8282
/// <para>Defaults to <c>TimeSpan.FromMinutes(1)</c> when null.</para>
8383
/// </summary>
84-
public TimeSpan? Timeout { get; set; }
84+
public TimeSpan? Timeout { get; set; } = null;
8585

8686
/// <summary>
8787
/// Customer API key for authentication. Use `sk_live_*` keys for production

src/Sentdm/Core/JsonDictionary.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ Dictionary<string, JsonElement> MutableRawData
3838
public JsonDictionary()
3939
{
4040
_rawData = new Dictionary<string, JsonElement>();
41-
_deserializedData = [];
41+
_deserializedData = new();
4242
}
4343

4444
public JsonDictionary(IReadOnlyDictionary<string, JsonElement> dictionary)
4545
{
4646
_rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value);
47-
_deserializedData = [];
47+
_deserializedData = new();
4848
}
4949

5050
public JsonDictionary(FrozenDictionary<string, JsonElement> dictionary)
5151
{
5252
_rawData = dictionary;
53-
_deserializedData = [];
53+
_deserializedData = new();
5454
}
5555

5656
public JsonDictionary(JsonDictionary dictionary)

src/Sentdm/Core/MultipartJsonDictionary.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ Dictionary<string, MultipartJsonElement> MutableRawData
3838
public MultipartJsonDictionary()
3939
{
4040
_rawData = new Dictionary<string, MultipartJsonElement>();
41-
_deserializedData = [];
41+
_deserializedData = new();
4242
}
4343

4444
public MultipartJsonDictionary(IReadOnlyDictionary<string, MultipartJsonElement> dictionary)
4545
{
4646
_rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value);
47-
_deserializedData = [];
47+
_deserializedData = new();
4848
}
4949

5050
public MultipartJsonDictionary(FrozenDictionary<string, MultipartJsonElement> dictionary)
5151
{
5252
_rawData = dictionary;
53-
_deserializedData = [];
53+
_deserializedData = new();
5454
}
5555

5656
public MultipartJsonDictionary(MultipartJsonDictionary dictionary)

src/Sentdm/Core/MultipartJsonElement.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace Sentdm.Core;
1515
///
1616
/// <para>Use <see cref="MultipartJsonSerializer"/> to construct or read instances of this class.</para>
1717
/// </summary>
18-
public readonly struct MultipartJsonElement()
18+
public readonly struct MultipartJsonElement
1919
{
2020
/// <summary>
2121
/// A <see cref="JsonElement"/> with <see cref="BinaryContents">placeholders</see>
2222
/// for <see cref="BinaryContent"/>.
2323
/// </summary>
24-
internal JsonElement Json { get; init; }
24+
internal JsonElement Json { get; init; } = default;
2525

2626
/// <summary>
2727
/// A dictionary from placeholder string in <see cref="Json">the JSON</see> to
@@ -32,6 +32,8 @@ public readonly struct MultipartJsonElement()
3232

3333
public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json };
3434

35+
public MultipartJsonElement() { }
36+
3537
public override string ToString() =>
3638
JsonSerializer.Serialize(
3739
FriendlyJsonPrinter.PrintValue(this),
@@ -176,7 +178,7 @@ internal static Dictionary<Guid, BinaryContent> BinaryContents
176178

177179
static readonly ThreadLocal<
178180
Dictionary<JsonSerializerOptions, JsonSerializerOptions>
179-
> MultipartSerializerOptionsCache = new(() => []);
181+
> MultipartSerializerOptionsCache = new(() => new());
180182

181183
static readonly JsonSerializerOptions DefaultMultipartSerializerOptions =
182184
MultipartSerializerOptions(new());
@@ -207,7 +209,7 @@ public static MultipartJsonElement SerializeToElement<T>(
207209
var previousBinaryContents = CurrentBinaryContents.Value;
208210
try
209211
{
210-
CurrentBinaryContents.Value = [];
212+
CurrentBinaryContents.Value = new();
211213
var element = JsonSerializer.SerializeToElement(
212214
value,
213215
MultipartSerializerOptions(options)
@@ -250,7 +252,7 @@ public static MultipartFormDataContent Serialize<T>(
250252
JsonSerializerOptions? options = null
251253
)
252254
{
253-
MultipartFormDataContent formDataContent = [];
255+
MultipartFormDataContent formDataContent = new();
254256
var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options);
255257
void SerializeParts(string name, JsonElement element)
256258
{

src/Sentdm/Core/ParamsBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ JsonElement element
158158

159159
internal string QueryString(ClientOptions options)
160160
{
161-
NameValueCollection collection = [];
161+
NameValueCollection collection = new();
162162
foreach (var item in this.RawQueryData)
163163
{
164164
ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value);
@@ -267,5 +267,10 @@ static Runtime GetRuntime()
267267
};
268268
}
269269

270-
readonly record struct Runtime(string Name, string Version);
270+
readonly record struct Runtime
271+
{
272+
public string Name { get; init; }
273+
274+
public string Version { get; init; }
275+
}
271276
}

src/Sentdm/Shims.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,36 @@ namespace System.Runtime.CompilerServices
1515
AllowMultiple = false,
1616
Inherited = false
1717
)]
18-
internal sealed class RequiredMemberAttribute : Attribute;
18+
internal sealed class RequiredMemberAttribute : Attribute { }
1919

2020
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
21-
internal sealed class CompilerFeatureRequiredAttribute(string feature) : Attribute;
21+
internal sealed class CompilerFeatureRequiredAttribute : Attribute
22+
{
23+
public CompilerFeatureRequiredAttribute(string feature) { }
24+
}
2225

2326
// Allow `init` to compile when targeting .NET Standard 2.0.
24-
internal static class IsExternalInit;
27+
internal static class IsExternalInit { }
2528
}
2629

2730
namespace System.Diagnostics.CodeAnalysis
2831
{
2932
// Allow `[SetsRequiredMembers]` to compile when targeting .NET Standard 2.0.
3033
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
31-
internal sealed class SetsRequiredMembersAttribute : Attribute;
34+
internal sealed class SetsRequiredMembersAttribute : Attribute { }
3235

3336
// Allow `[MaybeNullWhen(...)]` to compile when targeting .NET Standard 2.0.
3437
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
35-
internal sealed class MaybeNullWhenAttribute(bool returnValue) : Attribute;
38+
internal sealed class MaybeNullWhenAttribute : Attribute
39+
{
40+
public MaybeNullWhenAttribute(bool returnValue) { }
41+
}
3642

3743
// Allow `[NotNullWhen(...)]` to compile when targeting .NET Standard 2.0.
3844
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
39-
internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute;
45+
internal sealed class NotNullWhenAttribute : Attribute
46+
{
47+
public NotNullWhenAttribute(bool returnValue) { }
48+
}
4049
}
4150
#endif

0 commit comments

Comments
 (0)