From feea9bfd301719b1c5cd952d9b5a1e4991cfb82f Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Wed, 3 Dec 2014 09:48:54 -0500 Subject: [PATCH 1/2] Fix heuristic for .fs --- lib/linguist/heuristics.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index dd1585f85..c496b8f87 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -137,9 +137,9 @@ module Linguist disambiguate "F#", "Forth", "GLSL" do |data| if /^(: |new-device)/.match(data) Language["Forth"] - elsif /^(#light|import|let|module|namespace|open|type)/.match(data) + elsif /^\s*(#light|import|let|module|namespace|open|type)/.match(data) Language["F#"] - elsif /^(#include|#pragma|precision|uniform|varying|void)/.match(data) + elsif /^\s*(#include|#pragma|precision|uniform|varying|void)/.match(data) Language["GLSL"] end end From 351e348ac03fab49a132c205408d35909afea1aa Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Wed, 3 Dec 2014 10:07:54 -0500 Subject: [PATCH 2/2] New F# sample to test fix for .fs heuristics --- samples/F#/Combinators.fs | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 samples/F#/Combinators.fs diff --git a/samples/F#/Combinators.fs b/samples/F#/Combinators.fs new file mode 100644 index 000000000..409c524de --- /dev/null +++ b/samples/F#/Combinators.fs @@ -0,0 +1,49 @@ +namespace Nessos.FsPickler.Combinators + + open Nessos.FsPickler + open Nessos.FsPickler.Json + + /// Json pickling methods + [] + module Json = + + let private jsonSerializer = lazy(FsPickler.CreateJson(omitHeader = true)) + + /// + /// Pickles a value to Json. + /// + /// utilized pickler. + /// input value. + let pickle (pickler : Pickler<'T>) (value : 'T) : string = + jsonSerializer.Value.PickleToString (pickler, value) + + /// + /// Unpickles a value from Json. + /// + /// utilized pickler. + /// input pickle. + let unpickle (pickler : Pickler<'T>) (pickle : string) : 'T = + jsonSerializer.Value.UnPickleOfString (pickler, pickle) + + + /// Bson pickling methods + [] + module Bson = + + let private bsonPickler = lazy(FsPickler.CreateBson()) + + /// + /// Pickles a value to Bson. + /// + /// utilized pickler. + /// input value. + let pickle (pickler : Pickler<'T>) (value : 'T) : byte [] = + bsonPickler.Value.Pickle (pickler, value) + + /// + /// Unpickles a value from bson. + /// + /// utilized pickler. + /// input pickle. + let unpickle (pickler : Pickler<'T>) (pickle : byte []) : 'T = + bsonPickler.Value.UnPickle (pickler, pickle) \ No newline at end of file