Skip to content

Commit

Permalink
Merge pull request #1428 from stripe/ob-immutable-dict
Browse files Browse the repository at this point in the history
Make ObjectsToTypes dictionary immutable
  • Loading branch information
ob-stripe authored Dec 13, 2018
2 parents 791e42b + c82b595 commit 2995634
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Stripe.net/Infrastructure/StripeTypeRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Stripe.Infrastructure
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Reflection;

internal static class StripeTypeRegistry
Expand All @@ -10,7 +11,7 @@ internal static class StripeTypeRegistry
/// Dictionary mapping the values contained in the `object` key of JSON payloads returned
/// by Stripe's API to concrete types of model classes.
/// </summary>
public static readonly Dictionary<string, Type> ObjectsToTypes = new Dictionary<string, Type>
public static readonly ImmutableDictionary<string, Type> ObjectsToTypes = new Dictionary<string, Type>
{
{ "account", typeof(Account) },
{ "apple_pay_domain", typeof(ApplePayDomain) },
Expand Down Expand Up @@ -75,7 +76,7 @@ internal static class StripeTypeRegistry
{ "usage_record", typeof(UsageRecord) },
{ "usage_record_summary", typeof(UsageRecordSummary) },
{ "webhook_endpoint", typeof(WebhookEndpoint) },
};
}.ToImmutableDictionary();

/// <summary>
/// Returns the concrete type to use, given a potential type and the value of the `object`
Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Stripe.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand Down

0 comments on commit 2995634

Please sign in to comment.