Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Implement Serialization Framework and rework WireFormat #20

Merged
merged 20 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Core/EncodingTypes.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(*
* Types used for encoding and decoding raw fields, at the wire format level.
*)
namespace Froto.Core.Encoding

open System

/// Protobuf field wire-type
type WireType =
| Varint = 0
| Fixed64 = 1
| LengthDelimited = 2
| StartGroup = 3
| EndGroup = 4
| Fixed32 = 5

/// Protobuf field number
type FieldNum = int32

/// Raw unencoded wire-format field
type RawField =
| Varint of FieldNum * uint64
| Fixed32 of FieldNum * uint32
| Fixed64 of FieldNum * uint64
| LengthDelimited of FieldNum * ArraySegment<byte>
// | Group is deprecated & not supported
with
member x.FieldNum =
match x with
| Varint(n,_) -> n
| Fixed32(n,_) -> n
| Fixed64(n,_) -> n
| LengthDelimited(n,_) -> n
// Need a place to hang this, because it cannot go on FieldNum
// (a type alias cannot have methods or properties).
static member MaxFieldNum = (2<<<28) - 1
12 changes: 12 additions & 0 deletions Core/Exceptions.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Froto.Core

/// Exception encoding or decoding a Protobuf wireformat

type ProtobufException(message:string, ?innerException:exn) =
inherit System.ApplicationException( message, defaultArg innerException null )

type ProtobufWireFormatException (message:string, ?innerException:exn) =
inherit ProtobufException(message, defaultArg innerException null)

type ProtobufSerializerException (message:string, ?innerException:exn) =
inherit ProtobufException(message, defaultArg innerException null)
16 changes: 11 additions & 5 deletions Core/Froto.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets" />
<ItemGroup>
<Compile Include="Exceptions.fs" />
<Compile Include="ZeroCopyBuffer.fs" />
<Compile Include="EncodingTypes.fs" />
<Compile Include="WireFormat.fs" />
<Compile Include="Serializer.fs" />
<None Include="Froto.Core.nuspec" />
<None Include="paket.references" />
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="IO.fs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets" />
</Project>
</Project>
18 changes: 18 additions & 0 deletions Core/Froto.Core.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>Froto.Core</id>
<version>0.0.0</version>
<authors>Cameron Taggart, James Hugard</authors>
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
<projectUrl>https://github.com/ctaggart/froto</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A serailization library for Protocol Buffers.</description>
@dependencies@
<tags>froto protobuf binary protocol buffers serialization deserialization</tags>
</metadata>
<files>
<file src="Froto.Core.dll" target="lib\net45" />
<file src="Froto.Core.pdb" target="lib\net45" />
</files>
</package>
302 changes: 0 additions & 302 deletions Core/IO.fs

This file was deleted.

Loading