Skip to content

Commit

Permalink
Deconstruct outfield renamed
Browse files Browse the repository at this point in the history
this disambiguates the outfield with the member field name)
  • Loading branch information
Jimmy Byrd committed May 26, 2020
1 parent fad7f82 commit 0fdc94a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ module internal Create =
/// Allows for pattern matching against properties
let createDeconstruct =
let deconstructMethodName ="Deconstruct"

let outField str = sprintf "out%s" str
let memberArgs =
let arg argName fieldTy =
let create fieldTy =
Expand All @@ -485,7 +485,7 @@ module internal Create =
|> Seq.map(fun f ->
let rcd = f.ToRcd
let x = rcd.Id |> Option.get
let argRcd = arg x.idText rcd.Type
let argRcd = arg (outField x.idText) rcd.Type
argRcd
)
|> Seq.toList
Expand Down Expand Up @@ -515,7 +515,7 @@ module internal Create =
|> DSL.createInstanceMethodCallUnit
| None -> SynExpr.CreateLongIdent( LongIdentWithDots.Create [selfIden; fieldName ])

SynExpr.LongIdentSet (LongIdentWithDots.CreateString fieldName, rightside, range0 )
SynExpr.LongIdentSet (LongIdentWithDots.CreateString (outField fieldName), rightside, range0 )
)
|> DSL.sequentialExpressions

Expand Down
12 changes: 6 additions & 6 deletions tests/JsonWrapperPlugin.Tests/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("JsonWrapperPlugin.Tests")>]
[<assembly: AssemblyProductAttribute("BinaryDefense.JsonWrapper")>]
[<assembly: AssemblyVersionAttribute("0.1.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2017-03-17T00:00:00.0000000")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-05-25T00:00:00.0000000-04:00")>]
[<assembly: AssemblyFileVersionAttribute("0.1.0")>]
[<assembly: AssemblyInformationalVersionAttribute("0.1.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","16631e31433974cc1239286e90295985114bc1da")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","beta")>]
[<assembly: AssemblyMetadataAttribute("GitHash","d315af080825e2f1b2cc41d0e8f76597f1b55b82")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "JsonWrapperPlugin.Tests"
let [<Literal>] AssemblyProduct = "BinaryDefense.JsonWrapper"
let [<Literal>] AssemblyVersion = "0.1.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2017-03-17T00:00:00.0000000"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-05-25T00:00:00.0000000-04:00"
let [<Literal>] AssemblyFileVersion = "0.1.0"
let [<Literal>] AssemblyInformationalVersion = "0.1.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "16631e31433974cc1239286e90295985114bc1da"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "beta"
let [<Literal>] AssemblyMetadata_GitHash = "d315af080825e2f1b2cc41d0e8f76597f1b55b82"
50 changes: 22 additions & 28 deletions tests/JsonWrapperPlugin.Tests/Generated.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
//------------------------------------------------------------------------------
namespace rec DataSchema


namespace rec DataSchema


namespace rec DataSchema

open Newtonsoft.Json.Linq
open Newtonsoft.Json
open BinaryDefense.JsonWrapper.Core
Expand Down Expand Up @@ -44,10 +38,10 @@ type SimpleSchema(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<int>, two: outref<string>, three: outref<System.Guid>) =
one <- this.one
two <- this.two
three <- this.three
member this.Deconstruct(outone: outref<int>, outtwo: outref<string>, outthree: outref<System.Guid>) =
outone <- this.one
outtwo <- this.two
outthree <- this.three

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -75,9 +69,9 @@ type DifferentBackingFieldSchema(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<int>, two: outref<int>) =
one <- this.one
two <- this.two
member this.Deconstruct(outone: outref<int>, outtwo: outref<int>) =
outone <- this.one
outtwo <- this.two

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -105,9 +99,9 @@ type NullableFieldSchema(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<System.Nullable<int>>, two: outref<string>) =
one <- this.one
two <- this.two
member this.Deconstruct(outone: outref<System.Nullable<int>>, outtwo: outref<string>) =
outone <- this.one
outtwo <- this.two

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -137,9 +131,9 @@ type NullableMissingFieldSchema(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<System.Nullable<int>>, two: outref<int>) =
one <- this.one
two <- this.two
member this.Deconstruct(outone: outref<System.Nullable<int>>, outtwo: outref<int>) =
outone <- this.one
outtwo <- this.two

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -167,9 +161,9 @@ type OptionalFieldSchema(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<int option>, two: outref<int>) =
one <- this.one
two <- this.two
member this.Deconstruct(outone: outref<int option>, outtwo: outref<int>) =
outone <- this.one
outtwo <- this.two

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -197,9 +191,9 @@ type InnerType(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(one: outref<int option>, two: outref<string>) =
one <- this.one
two <- this.two
member this.Deconstruct(outone: outref<int option>, outtwo: outref<string>) =
outone <- this.one
outtwo <- this.two

interface IHaveJToken with
override this.InnerData = jtoken
Expand Down Expand Up @@ -227,9 +221,9 @@ type OuterType(jtoken: JToken, serializer: JsonSerializer) =
| _ -> false

///This allows the class to be pattern matched against
member this.Deconstruct(foo: outref<int option * string>, count: outref<int>) =
foo <- this.foo.Deconstruct()
count <- this.count
member this.Deconstruct(outfoo: outref<int option * string>, outcount: outref<int>) =
outfoo <- this.foo.Deconstruct()
outcount <- this.count

interface IHaveJToken with
override this.InnerData = jtoken
49 changes: 23 additions & 26 deletions tests/JsonWrapperPlugin.Tests/JsonWrapperPlugin.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<LangVersion>preview</LangVersion>
<!-- <MyriadSdkVerboseOutput>true</MyriadSdkVerboseOutput> -->
<!-- <MyriadSdkWaitForDebugger>true</MyriadSdkWaitForDebugger> -->
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Types.fs" />
<Compile Include="Generated.fs">
<MyriadFile>Types.fs</MyriadFile>
<MyriadNameSpace>DataSchema</MyriadNameSpace>
</Compile>
<Compile Include="Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/BinaryDefense.Myriad.Plugins.JsonWrapper/BinaryDefense.Myriad.Plugins.JsonWrapper.fsproj" />
<ProjectReference Include="..\..\src\BinaryDefense.JsonWrapper.Core\BinaryDefense.JsonWrapper.Core.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />

<Import Project="..\..\src\BinaryDefense.Myriad.Plugins.JsonWrapper\build\BinaryDefense.Myriad.Plugins.JsonWrapper.InTest.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<LangVersion>preview</LangVersion>
<!-- <MyriadSdkVerboseOutput>true</MyriadSdkVerboseOutput>
<MyriadSdkWaitForDebugger>true</MyriadSdkWaitForDebugger> -->
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Types.fs" />
<Compile Include="Generated.fs">
<MyriadFile>Types.fs</MyriadFile>
<MyriadNameSpace>DataSchema</MyriadNameSpace>
</Compile>
<Compile Include="Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/BinaryDefense.Myriad.Plugins.JsonWrapper/BinaryDefense.Myriad.Plugins.JsonWrapper.fsproj" />
<ProjectReference Include="..\..\src\BinaryDefense.JsonWrapper.Core\BinaryDefense.JsonWrapper.Core.fsproj" />
</ItemGroup>
<Import Project="..\..\src\BinaryDefense.Myriad.Plugins.JsonWrapper\build\BinaryDefense.Myriad.Plugins.JsonWrapper.InTest.props" />
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

0 comments on commit 0fdc94a

Please sign in to comment.