Skip to content
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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.12.0"
".": "0.12.1"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 40
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-294831f61f7890b2cdb89d181f26297732387d5e1288f446c0138e46fb1a4608.yml
openapi_spec_hash: a7f20451621ee678fbe09ff7a297b3ea
config_hash: 478a49d5520c8bb64b43272de11c2872
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-428b5bd5ea0fa3696fae9b7f20e1a3ac9c4c9c47c47621b10e6cc48e02df848f.yml
openapi_spec_hash: 0b20ca0dc74c7a00efb2fe2fc306a2ae
config_hash: d8e8429147c4e214ff53c11e7ab2a1a6
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.12.1 (2026-03-12)

Full Changelog: [v0.12.0...v0.12.1](https://github.com/sentdm/sent-dm-csharp/compare/v0.12.0...v0.12.1)

### Chores

* **client:** update formatting ([236e8cc](https://github.com/sentdm/sent-dm-csharp/commit/236e8cc96b98c2822f530799bffa4cf2f4295e5d))

## 0.12.0 (2026-03-12)

Full Changelog: [v0.11.0...v0.12.0](https://github.com/sentdm/sent-dm-csharp/compare/v0.11.0...v0.12.0)
Expand Down
27 changes: 17 additions & 10 deletions src/Sentdm/Core/ApiEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,26 @@ namespace Sentdm.Core;
///
/// <para>In most cases you don't have to worry about this type and can rely on its implicit operators to
/// wrap and unwrap enum values.</para>
///
/// <param name="Json">
/// Returns this instance's raw value.
///
/// <para>This is usually only useful if this instance was deserialized from data that doesn't match the
/// expected type (<typeparamref name="TRaw"/>), and you want to know that value. For example, if the
/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is
/// unaware of.</para>
/// </param>
/// </summary>
public record class ApiEnum<TRaw, TEnum>(JsonElement Json)
public record class ApiEnum<TRaw, TEnum>
where TEnum : struct, Enum
{
/// <summary>
/// Returns this instance's raw value.
///
/// <para>This is usually only useful if this instance was deserialized from data that doesn't match the
/// expected type (<typeparamref name="TRaw"/>), and you want to know that value. For example, if the
/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is
/// unaware of.
/// </para>
/// </summary>
public JsonElement Json;

public ApiEnum(JsonElement json)
{
Json = json;
}

/// <summary>
/// Returns this instance's raw <typeparamref name="TRaw"/> value.
///
Expand Down
4 changes: 2 additions & 2 deletions src/Sentdm/Core/ClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public string BaseUrl
/// <para>Defaults to 2 when null. Set to 0 to
/// disable retries, which also ignores API instructions to retry.</para>
/// </summary>
public int? MaxRetries { get; set; }
public int? MaxRetries { get; set; } = null;

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

/// <summary>
/// Customer API key for authentication. Use `sk_live_*` keys for production
Expand Down
6 changes: 3 additions & 3 deletions src/Sentdm/Core/JsonDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ Dictionary<string, JsonElement> MutableRawData
public JsonDictionary()
{
_rawData = new Dictionary<string, JsonElement>();
_deserializedData = [];
_deserializedData = new();
}

public JsonDictionary(IReadOnlyDictionary<string, JsonElement> dictionary)
{
_rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value);
_deserializedData = [];
_deserializedData = new();
}

public JsonDictionary(FrozenDictionary<string, JsonElement> dictionary)
{
_rawData = dictionary;
_deserializedData = [];
_deserializedData = new();
}

public JsonDictionary(JsonDictionary dictionary)
Expand Down
6 changes: 3 additions & 3 deletions src/Sentdm/Core/MultipartJsonDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ Dictionary<string, MultipartJsonElement> MutableRawData
public MultipartJsonDictionary()
{
_rawData = new Dictionary<string, MultipartJsonElement>();
_deserializedData = [];
_deserializedData = new();
}

public MultipartJsonDictionary(IReadOnlyDictionary<string, MultipartJsonElement> dictionary)
{
_rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value);
_deserializedData = [];
_deserializedData = new();
}

public MultipartJsonDictionary(FrozenDictionary<string, MultipartJsonElement> dictionary)
{
_rawData = dictionary;
_deserializedData = [];
_deserializedData = new();
}

public MultipartJsonDictionary(MultipartJsonDictionary dictionary)
Expand Down
12 changes: 7 additions & 5 deletions src/Sentdm/Core/MultipartJsonElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Sentdm.Core;
///
/// <para>Use <see cref="MultipartJsonSerializer"/> to construct or read instances of this class.</para>
/// </summary>
public readonly struct MultipartJsonElement()
public readonly struct MultipartJsonElement
{
/// <summary>
/// A <see cref="JsonElement"/> with <see cref="BinaryContents">placeholders</see>
/// for <see cref="BinaryContent"/>.
/// </summary>
internal JsonElement Json { get; init; }
internal JsonElement Json { get; init; } = default;

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

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

public MultipartJsonElement() { }

public override string ToString() =>
JsonSerializer.Serialize(
FriendlyJsonPrinter.PrintValue(this),
Expand Down Expand Up @@ -176,7 +178,7 @@ internal static Dictionary<Guid, BinaryContent> BinaryContents

static readonly ThreadLocal<
Dictionary<JsonSerializerOptions, JsonSerializerOptions>
> MultipartSerializerOptionsCache = new(() => []);
> MultipartSerializerOptionsCache = new(() => new());

static readonly JsonSerializerOptions DefaultMultipartSerializerOptions =
MultipartSerializerOptions(new());
Expand Down Expand Up @@ -207,7 +209,7 @@ public static MultipartJsonElement SerializeToElement<T>(
var previousBinaryContents = CurrentBinaryContents.Value;
try
{
CurrentBinaryContents.Value = [];
CurrentBinaryContents.Value = new();
var element = JsonSerializer.SerializeToElement(
value,
MultipartSerializerOptions(options)
Expand Down Expand Up @@ -250,7 +252,7 @@ public static MultipartFormDataContent Serialize<T>(
JsonSerializerOptions? options = null
)
{
MultipartFormDataContent formDataContent = [];
MultipartFormDataContent formDataContent = new();
var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options);
void SerializeParts(string name, JsonElement element)
{
Expand Down
9 changes: 7 additions & 2 deletions src/Sentdm/Core/ParamsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ JsonElement element

internal string QueryString(ClientOptions options)
{
NameValueCollection collection = [];
NameValueCollection collection = new();
foreach (var item in this.RawQueryData)
{
ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value);
Expand Down Expand Up @@ -267,5 +267,10 @@ static Runtime GetRuntime()
};
}

readonly record struct Runtime(string Name, string Version);
readonly record struct Runtime
{
public string Name { get; init; }

public string Version { get; init; }
}
}
2 changes: 1 addition & 1 deletion src/Sentdm/Sentdm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Metadata -->
<AssemblyTitle>Sent Dm C#</AssemblyTitle>
<AssemblyName>Sentdm</AssemblyName>
<VersionPrefix>0.12.0</VersionPrefix>
<VersionPrefix>0.12.1</VersionPrefix>
<Description>The official .NET library for the Sent Dm API.</Description>
<OutputType>Library</OutputType>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
21 changes: 15 additions & 6 deletions src/Sentdm/Shims.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,36 @@ namespace System.Runtime.CompilerServices
AllowMultiple = false,
Inherited = false
)]
internal sealed class RequiredMemberAttribute : Attribute;
internal sealed class RequiredMemberAttribute : Attribute { }

[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
internal sealed class CompilerFeatureRequiredAttribute(string feature) : Attribute;
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public CompilerFeatureRequiredAttribute(string feature) { }
}

// Allow `init` to compile when targeting .NET Standard 2.0.
internal static class IsExternalInit;
internal static class IsExternalInit { }
}

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

// Allow `[MaybeNullWhen(...)]` to compile when targeting .NET Standard 2.0.
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
internal sealed class MaybeNullWhenAttribute(bool returnValue) : Attribute;
internal sealed class MaybeNullWhenAttribute : Attribute
{
public MaybeNullWhenAttribute(bool returnValue) { }
}

// Allow `[NotNullWhen(...)]` to compile when targeting .NET Standard 2.0.
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute;
internal sealed class NotNullWhenAttribute : Attribute
{
public NotNullWhenAttribute(bool returnValue) { }
}
}
#endif
Loading