Skip to content

Commit

Permalink
Use built-in snake-casing implementation in .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawxy authored and oskardudycz committed Dec 11, 2023
1 parent 899a636 commit 89ce400
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Marten/Services/Json/SnakeCaseNamingPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Text.Json;

#if NET6_0 || NET7_0
namespace Marten.Services.Json;

// OD: Should not be needed after .NET 6.0 (based on https://github.com/dotnet/runtime/issues/782#issuecomment-673029718)
Expand Down Expand Up @@ -83,3 +84,4 @@ public override string ConvertName(string name)
return builder.ToString();
}
}
#endif
4 changes: 4 additions & 0 deletions src/Marten/Services/SystemTextJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ public EnumStorage EnumStorage
var jsonNamingPolicy = _casing switch
{
Casing.CamelCase => JsonNamingPolicy.CamelCase,
#if NET8_0
Casing.SnakeCase => JsonNamingPolicy.SnakeCaseLower,
#else
Casing.SnakeCase => new JsonSnakeCaseNamingPolicy(),
#endif
_ => null
};

Expand Down

0 comments on commit 89ce400

Please sign in to comment.