From c2844aaf1cfa4213393b6be9e6a340de7f04f651 Mon Sep 17 00:00:00 2001 From: Ramya Rao Date: Mon, 14 Apr 2025 16:37:38 -0700 Subject: [PATCH 1/4] Bump version to 48.0.1 --- CHANGELOG.md | 3 +++ VERSION | 2 +- src/Stripe.net/Constants/Version.cs | 2 +- src/Stripe.net/Stripe.net.csproj | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0612fffb9c..46fef9aa7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 48.0.1 - 2025-04-14 +* [#3090](https://github.com/stripe/stripe-dotnet/pull/3090) Disable Json.NET metadata special handling. Fixes issue [#3068](https://github.com/stripe/stripe-dotnet/issues/3068) + ## 48.0.0 - 2025-04-01 * [#3074](https://github.com/stripe/stripe-dotnet/pull/3074) System.Text.Json Serialization Support release to GA * Add System.Text.Json support for serializing Stripe.net entities and objects for applications running on .NET 6 and above. Now you can pass a Stripe.net object or collection of objects to the System.Text.Json serializer and it will produce the correct JSON string. diff --git a/VERSION b/VERSION index adb9d57dcf..587cdd12f3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -48.0.0 +48.0.1 diff --git a/src/Stripe.net/Constants/Version.cs b/src/Stripe.net/Constants/Version.cs index 988ac9b7aa..87ee4c5381 100644 --- a/src/Stripe.net/Constants/Version.cs +++ b/src/Stripe.net/Constants/Version.cs @@ -2,6 +2,6 @@ namespace Stripe { internal class Version { - public const string Current = "48.0.0"; + public const string Current = "48.0.1"; } } \ No newline at end of file diff --git a/src/Stripe.net/Stripe.net.csproj b/src/Stripe.net/Stripe.net.csproj index 00d97beaa3..e9409590cf 100644 --- a/src/Stripe.net/Stripe.net.csproj +++ b/src/Stripe.net/Stripe.net.csproj @@ -2,7 +2,7 @@ Stripe.net is a sync/async client and portable class library for the Stripe API, supporting .NET Standard 2.0+, .NET Core 3.1+, and .NET Framework 4.6.1+. (Official Library) - 48.0.0 + 48.0.1 8 Stripe, Jayme Davis net5.0;net6.0;net7.0;net8.0;netcoreapp3.1;netstandard2.0;net461 From b2779113183f0284323af40d305f82cd8632347a Mon Sep 17 00:00:00 2001 From: jar-stripe Date: Mon, 14 Apr 2025 18:09:42 -0700 Subject: [PATCH 2/4] replaced Dictionary with ConcurrentDictionary (#3101) --- .../SerializablePropertyCache.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Stripe.net/Infrastructure/JsonConverters/SerializablePropertyCache.cs b/src/Stripe.net/Infrastructure/JsonConverters/SerializablePropertyCache.cs index f7bbece3a7..bacfe7b40c 100644 --- a/src/Stripe.net/Infrastructure/JsonConverters/SerializablePropertyCache.cs +++ b/src/Stripe.net/Infrastructure/JsonConverters/SerializablePropertyCache.cs @@ -2,6 +2,7 @@ namespace Stripe.Infrastructure { using System; + using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; using System.Text.Json; @@ -13,17 +14,17 @@ namespace Stripe.Infrastructure /// internal class SerializablePropertyCache { - private static Dictionary converterCache = new Dictionary(); - private static Dictionary> propertyCache = new Dictionary>(); + private static ConcurrentDictionary converterCache = new ConcurrentDictionary(); + private static ConcurrentDictionary> propertyCache = new ConcurrentDictionary>(); internal static List GetPropertiesForType(Type type) { - if (!propertyCache.TryGetValue(type, out var propsToSerialize)) + return propertyCache.GetOrAdd(type, (key) => { // Gets the all properties including nonpublic properties var rawProps = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); - propsToSerialize = new List(); + var propsToSerialize = new List(); foreach (var prop in rawProps) { var propertyNameAttribute = prop.GetCustomAttribute(typeof(JsonPropertyNameAttribute), false) as JsonPropertyNameAttribute; @@ -55,10 +56,8 @@ internal static List GetPropertiesForType(Type type) }); } - propertyCache[type] = propsToSerialize; - } - - return propsToSerialize; + return propsToSerialize; + }); } // Create the various methods stored in SerializablePropertyInfo @@ -169,11 +168,10 @@ private static Action CreateSetDelegate(MethodInfo m) private static JsonConverter GetConverterForType(Type ct) where T : JsonConverter { - if (!converterCache.TryGetValue(ct, out var conv)) + var conv = converterCache.GetOrAdd(ct, (key) => { - conv = (JsonConverter)Activator.CreateInstance(ct); - converterCache[ct] = conv; - } + return (JsonConverter)Activator.CreateInstance(ct); + }); return new JsonConverterAdapter((T)conv); } From a16eae1fadd76b29698b5dd2124b0337e84ef997 Mon Sep 17 00:00:00 2001 From: Ramya Rao Date: Tue, 15 Apr 2025 11:00:09 -0700 Subject: [PATCH 3/4] Bump version to 48.0.2 --- CHANGELOG.md | 3 +++ VERSION | 2 +- src/Stripe.net/Constants/Version.cs | 2 +- src/Stripe.net/Stripe.net.csproj | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fef9aa7a..49cd0876a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 48.0.2 - 2025-04-15 +* [#3101](https://github.com/stripe/stripe-dotnet/pull/3101) Replace Dictionary with ConcurrentDictionary in SerializablePropertyCache to fix a concurrency related error reported in [#3100](https://github.com/stripe/stripe-dotnet/issues/3100) + ## 48.0.1 - 2025-04-14 * [#3090](https://github.com/stripe/stripe-dotnet/pull/3090) Disable Json.NET metadata special handling. Fixes issue [#3068](https://github.com/stripe/stripe-dotnet/issues/3068) diff --git a/VERSION b/VERSION index 587cdd12f3..0c27087fee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -48.0.1 +48.0.2 diff --git a/src/Stripe.net/Constants/Version.cs b/src/Stripe.net/Constants/Version.cs index 87ee4c5381..9c6842553d 100644 --- a/src/Stripe.net/Constants/Version.cs +++ b/src/Stripe.net/Constants/Version.cs @@ -2,6 +2,6 @@ namespace Stripe { internal class Version { - public const string Current = "48.0.1"; + public const string Current = "48.0.2"; } } \ No newline at end of file diff --git a/src/Stripe.net/Stripe.net.csproj b/src/Stripe.net/Stripe.net.csproj index e9409590cf..b75e797d3f 100644 --- a/src/Stripe.net/Stripe.net.csproj +++ b/src/Stripe.net/Stripe.net.csproj @@ -2,7 +2,7 @@ Stripe.net is a sync/async client and portable class library for the Stripe API, supporting .NET Standard 2.0+, .NET Core 3.1+, and .NET Framework 4.6.1+. (Official Library) - 48.0.1 + 48.0.2 8 Stripe, Jayme Davis net5.0;net6.0;net7.0;net8.0;netcoreapp3.1;netstandard2.0;net461 From f7bf7b8490236c8a88d0212c1b58a5d1f6843a17 Mon Sep 17 00:00:00 2001 From: jar-stripe Date: Thu, 17 Apr 2025 13:50:01 -0700 Subject: [PATCH 4/4] changed ContentEncoder to emit lowercase true/false for boolean params (#3104) updated tests --- .../Infrastructure/FormEncoding/ContentEncoder.cs | 6 ++++++ .../Infrastructure/FormEncoding/ContentEncoderTest.cs | 4 ++-- .../PaymentIntents/PaymentIntentConfirmOptionsTest.cs | 2 +- .../PaymentIntents/PaymentIntentCreateOptionsTest.cs | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Stripe.net/Infrastructure/FormEncoding/ContentEncoder.cs b/src/Stripe.net/Infrastructure/FormEncoding/ContentEncoder.cs index 3bc7d8aa22..aeb2453cc8 100644 --- a/src/Stripe.net/Infrastructure/FormEncoding/ContentEncoder.cs +++ b/src/Stripe.net/Infrastructure/FormEncoding/ContentEncoder.cs @@ -163,6 +163,12 @@ private static List> FlattenParamsValue(object valu flatParams = SingleParam(keyPrefix, JsonUtils.SerializeObject(e).Trim('"')); break; + case bool b: + flatParams = SingleParam( + keyPrefix, + b ? "true" : "false"); + break; + default: flatParams = SingleParam( keyPrefix, diff --git a/src/StripeTests/Infrastructure/FormEncoding/ContentEncoderTest.cs b/src/StripeTests/Infrastructure/FormEncoding/ContentEncoderTest.cs index 09602f3268..2953e0eba0 100644 --- a/src/StripeTests/Infrastructure/FormEncoding/ContentEncoderTest.cs +++ b/src/StripeTests/Infrastructure/FormEncoding/ContentEncoderTest.cs @@ -205,7 +205,7 @@ public void CreateQueryString() { Bool = false, }, - Want = "bool=False", + Want = "bool=false", }, new QueryStringTestCase { @@ -213,7 +213,7 @@ public void CreateQueryString() { Bool = true, }, - Want = "bool=True", + Want = "bool=true", }, // DateRangeOptions diff --git a/src/StripeTests/Services/PaymentIntents/PaymentIntentConfirmOptionsTest.cs b/src/StripeTests/Services/PaymentIntents/PaymentIntentConfirmOptionsTest.cs index 9e9b6f01c8..2a049aefcb 100644 --- a/src/StripeTests/Services/PaymentIntents/PaymentIntentConfirmOptionsTest.cs +++ b/src/StripeTests/Services/PaymentIntents/PaymentIntentConfirmOptionsTest.cs @@ -14,7 +14,7 @@ public void SerializeObjectProperly() OffSession = true, }; - Assert.Equal("off_session=True", ContentEncoder.CreateQueryString(options_bool)); + Assert.Equal("off_session=true", ContentEncoder.CreateQueryString(options_bool)); } } } diff --git a/src/StripeTests/Services/PaymentIntents/PaymentIntentCreateOptionsTest.cs b/src/StripeTests/Services/PaymentIntents/PaymentIntentCreateOptionsTest.cs index 011ca022a0..ea099904b7 100644 --- a/src/StripeTests/Services/PaymentIntents/PaymentIntentCreateOptionsTest.cs +++ b/src/StripeTests/Services/PaymentIntents/PaymentIntentCreateOptionsTest.cs @@ -14,7 +14,7 @@ public void SerializeObjectProperly() OffSession = true, }; - Assert.Equal("off_session=True", ContentEncoder.CreateQueryString(options_bool)); + Assert.Equal("off_session=true", ContentEncoder.CreateQueryString(options_bool)); } } }