Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Equinox.Codec out to FsCodec #156

Merged
merged 13 commits into from
Aug 30, 2019
Prev Previous commit
Next Next commit
rename NewtonsoftJson.Json -> Codec
  • Loading branch information
bartelink committed Aug 29, 2019
commit 7980c1990be3e02fe81751c09f012b84b1ec2fb8
2 changes: 1 addition & 1 deletion samples/Infrastructure/Services.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ let register (services : IServiceCollection, storageConfig, handlerLog, codecGen
let serializationSettings = Newtonsoft.Json.Converters.FSharp.Settings.CreateCorrect()
type NewtonsoftJsonCodecGen() =
interface ICodecGen with
member __.Generate() = Gardelloyd.NewtonsoftJson.Json.Create<'Union>(serializationSettings)
member __.Generate() = Gardelloyd.NewtonsoftJson.Codec.Create<'Union>(serializationSettings)
2 changes: 1 addition & 1 deletion samples/Store/Integration/CodecIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let serializationSettings =
Newtonsoft.Json.Converters.FSharp.OptionConverter() |])

let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() =
Gardelloyd.NewtonsoftJson.Json.Create<'Union>(serializationSettings)
Gardelloyd.NewtonsoftJson.Codec.Create<'Union>(serializationSettings)

type EventWithId = { id : CartId } // where CartId uses FSharp.UMX

Expand Down
2 changes: 1 addition & 1 deletion samples/Store/Integration/EventStoreIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Equinox.EventStore
open System

let serializationSettings = Newtonsoft.Json.Converters.FSharp.Settings.CreateCorrect()
let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() = Gardelloyd.NewtonsoftJson.Json.Create<'Union>(serializationSettings)
let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() = Gardelloyd.NewtonsoftJson.Codec.Create<'Union>(serializationSettings)

/// Connect with Gossip based cluster discovery using the default Commercial edition Manager port config
/// Such a config can be simulated on a single node with zero config via the EventStore OSS package:-
Expand Down
2 changes: 1 addition & 1 deletion samples/Tutorial/Cosmos.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module Store =
let cacheStrategy = CachingStrategy.SlidingWindow (cache, TimeSpan.FromMinutes 20.) // OR CachingStrategy.NoCaching

module FavoritesCategory =
let codec = Gardelloyd.NewtonsoftJson.Json.Create<Favorites.Event>(Newtonsoft.Json.JsonSerializerSettings())
let codec = Gardelloyd.NewtonsoftJson.Codec.Create<Favorites.Event>(Newtonsoft.Json.JsonSerializerSettings())
let resolve = Resolver(Store.context, codec, Favorites.fold, Favorites.initial, Store.cacheStrategy).Resolve

let service = Favorites.Service(Log.log, FavoritesCategory.resolve)
Expand Down
2 changes: 1 addition & 1 deletion samples/Tutorial/Todo.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module Store =
let cacheStrategy = CachingStrategy.SlidingWindow (cache, TimeSpan.FromMinutes 20.)

module TodosCategory =
let codec = Gardelloyd.NewtonsoftJson.Json.Create<Event>(Newtonsoft.Json.JsonSerializerSettings())
let codec = Gardelloyd.NewtonsoftJson.Codec.Create<Event>(Newtonsoft.Json.JsonSerializerSettings())
let access = AccessStrategy.Snapshot (isOrigin,compact)
let resolve = Resolver(Store.store, codec, fold, initial, Store.cacheStrategy, access=access).Resolve

Expand Down
2 changes: 1 addition & 1 deletion src/Gardelloyd.NewtonsoftJson/NewtonsoftJson.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module Core =

/// Provides Codecs that render to a UTF-8 array suitable for storage in EventStore or CosmosDb based on explicit functions you supply using `Newtonsoft.Json` and
/// `TypeShape.UnionContract.UnionContractEncoder` - if you need full control and/or have have your own codecs, see `Gardelloyd.Custom.Create` instead
type Json =
type Codec =

/// <summary>
/// Generate a codec suitable for use with <c>Equinox.EventStore</c> or <c>Equinox.Cosmos</c>,
Expand Down
2 changes: 1 addition & 1 deletion src/Gardelloyd/Gardelloyd.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type IUnionEncoder<'Union, 'Format> =
abstract TryDecode : encoded:IEvent<'Format> -> 'Union option

/// Provides Codecs that render to a UTF-8 array suitable for storage in EventStore or CosmosDb based on explicit functions you supply
/// i.e., with using conventions / Type Shapes / Reflection or specific Json processing libraries - see Gardelloyd.NewtonsoftJson.Json for batteries-included Coding/Decoding
/// i.e., with using conventions / Type Shapes / Reflection or specific Json processing libraries - see Gardelloyd.NewtonsoftJson.Codec for batteries-included Coding/Decoding
type Custom =

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion tests/Equinox.Cosmos.Integration/CosmosIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open System

let serializationSettings = JsonSerializerSettings()
let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() =
Gardelloyd.NewtonsoftJson.Json.Create<'Union>(serializationSettings)
Gardelloyd.NewtonsoftJson.Codec.Create<'Union>(serializationSettings)

module Cart =
let fold, initial = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial
Expand Down
10 changes: 5 additions & 5 deletions tests/Equinox.Cosmos.Integration/JsonConverterTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Union =
interface TypeShape.UnionContract.IUnionContract

let defaultSettings = JsonSerializerSettings()
let mkUnionEncoder () = Gardelloyd.NewtonsoftJson.Json.Create<Union>(defaultSettings)
let mkUnionEncoder () = Gardelloyd.NewtonsoftJson.Codec.Create<Union>(defaultSettings)

type EmbeddedString = { embed : string }
type EmbeddedDate = { embed : DateTime }
Expand Down Expand Up @@ -47,7 +47,7 @@ type VerbatimUtf8Tests() =
let res = JsonConvert.SerializeObject(e)
test <@ res.Contains """"d":{"embed":"\""}""" @>

let uEncoder = Gardelloyd.NewtonsoftJson.Json.Create<U>(defaultSettings)
let uEncoder = Gardelloyd.NewtonsoftJson.Codec.Create<U>(defaultSettings)

let [<Property(MaxTest=100)>] ``roundtrips diverse bodies correctly`` (x: U) =
let encoded = uEncoder.Encode x
Expand All @@ -62,15 +62,15 @@ type VerbatimUtf8Tests() =

// NB while this aspect works, we don't support it as it gets messy when you then use the VerbatimUtf8Converter
// https://github.com/JamesNK/Newtonsoft.Json/issues/862 // doesnt apply to this case
let [<Fact>] ``Gardelloyd.NewtonsoftJson.Json does not fall prey to Date-strings being mutilated`` () =
let [<Fact>] ``Gardelloyd.NewtonsoftJson.Codec does not fall prey to Date-strings being mutilated`` () =
let x = ES { embed = "2016-03-31T07:02:00+07:00" }
let encoded = uEncoder.Encode x
let decoded = uEncoder.TryDecode encoded |> Option.get
test <@ x = decoded @>

//// NB while this aspect works, we don't support it as it gets messy when you then use the VerbatimUtf8Converter
//let sEncoder = Gardelloyd.NewtonsoftJson.Json.Create<US>(defaultSettings)
//let [<Theory; InlineData ""; InlineData null>] ``Gardelloyd.NewtonsoftJson.Json can roundtrip strings`` (value: string) =
//let sEncoder = Gardelloyd.NewtonsoftJson.Codec.Create<US>(defaultSettings)
//let [<Theory; InlineData ""; InlineData null>] ``Gardelloyd.NewtonsoftJson.Codec can roundtrip strings`` (value: string) =
// let x = SS value
// let encoded = sEncoder.Encode x
// let decoded = sEncoder.TryDecode encoded |> Option.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let createGesGateway connection batchSize = Context(connection, BatchingPolicy(m

let serializationSettings = JsonSerializerSettings()
let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() =
Gardelloyd.NewtonsoftJson.Json.Create<'Union>(serializationSettings)
Gardelloyd.NewtonsoftJson.Codec.Create<'Union>(serializationSettings)

module Cart =
let fold, initial = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial
Expand Down