Skip to content

Commit 21e8052

Browse files
chore(client): update formatting
1 parent f8d96a9 commit 21e8052

File tree

7 files changed

+54
-31
lines changed

7 files changed

+54
-31
lines changed

src/Orb/Core/ApiEnum.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ namespace Orb.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/Orb/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
Lazy<string> _apiKey = new(() =>
8787
Environment.GetEnvironmentVariable("ORB_API_KEY")

src/Orb/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/Orb/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/Orb/Core/MultipartJsonElement.cs

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

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

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

34+
public MultipartJsonElement() { }
35+
3436
public override string ToString() =>
3537
JsonSerializer.Serialize(
3638
FriendlyJsonPrinter.PrintValue(this),
@@ -175,7 +177,7 @@ internal static Dictionary<Guid, BinaryContent> BinaryContents
175177

176178
static readonly ThreadLocal<
177179
Dictionary<JsonSerializerOptions, JsonSerializerOptions>
178-
> MultipartSerializerOptionsCache = new(() => []);
180+
> MultipartSerializerOptionsCache = new(() => new());
179181

180182
static readonly JsonSerializerOptions DefaultMultipartSerializerOptions =
181183
MultipartSerializerOptions(new());
@@ -206,7 +208,7 @@ public static MultipartJsonElement SerializeToElement<T>(
206208
var previousBinaryContents = CurrentBinaryContents.Value;
207209
try
208210
{
209-
CurrentBinaryContents.Value = [];
211+
CurrentBinaryContents.Value = new();
210212
var element = JsonSerializer.SerializeToElement(
211213
value,
212214
MultipartSerializerOptions(options)
@@ -249,7 +251,7 @@ public static MultipartFormDataContent Serialize<T>(
249251
JsonSerializerOptions? options = null
250252
)
251253
{
252-
MultipartFormDataContent formDataContent = [];
254+
MultipartFormDataContent formDataContent = new();
253255
var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options);
254256
void SerializeParts(string name, JsonElement element)
255257
{

src/Orb/Core/ParamsBase.cs

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

154154
internal string QueryString(ClientOptions options)
155155
{
156-
NameValueCollection collection = [];
156+
NameValueCollection collection = new();
157157
foreach (var item in this.RawQueryData)
158158
{
159159
ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value);
@@ -262,5 +262,10 @@ static Runtime GetRuntime()
262262
};
263263
}
264264

265-
readonly record struct Runtime(string Name, string Version);
265+
readonly record struct Runtime
266+
{
267+
public string Name { get; init; }
268+
269+
public string Version { get; init; }
270+
}
266271
}

src/Orb/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)