Order of fields in a type for FileHelpers


I'm reading a simple CSV file with Filehelpers - the file is just a key, value pair. (string, int64)

The f# type I've written for this is:

type MapVal (key:string, value:int64) = new()= MapVal("",0L) member x.Key = key member x.Value = value

I'm missing something elementary here, but FileHelpers always assumes the order of fields to be the reverse of what I've specified - as in Value, Key.

let dfe = new DelimitedFileEngine(typeof<MapVal>) let recs = dfe.ReadFile(@"D:\e.dat") recs |> Seq.length

What am I missing here?


The order of primary constructor parameters doesn't necessarily determine the order that fields occur within a type (in fact, depending on how the parameters are used, they may not even result in a field being generated). The fact that FileHelpers doesn't provide a way to use properties instead of fields is unforunate, in my opinion. If you want better control over the physical layout of the class, you'll need to declare the fields explicitly:

type MapVal = val mutable key : string val mutable value : int64 new() = { key = ""; value = 0L } new(k, v) = { key = k; value = v } member x.Key = x.key member x.Value = x.value


The library uses the order of the field in the declaration, but looks like that F# words different, in the last the last stable version of the library you can use the [FieldOrder(1)] attribute to provide the order of the fields.

<a href="http://teamcity.codebetter.com/viewLog.html?buildId=lastSuccessful&buildTypeId=bt66&tab=artifacts&guest=1" rel="nofollow">http://teamcity.codebetter.com/viewLog.html?buildId=lastSuccessful&buildTypeId=bt66&tab=artifacts&guest=1</a>



  • React Set a State of a component as part of a Form State
  • day05
  • How to stop my character from over rotating with zRotation constraints?
  • Java: relative path for data file
  • RequestBody JSON format has single quotes
  • How to move first N elements to the end of the list
  • Win 8 RT routing parameters
  • How to rename items by assigning sequential number?
  • textarea auto expand
  • Create a Contact form in Angular 2 / 4 that POSTS JSON to a specified API
  • How can I encrypt data using a public key from ECC X509 certificate in .net framework on windows?
  • How to get similarties and differences between two images using Opencv
  • How to extract details from the xml files using java?
  • ORA-02253: constraint specification not allowed here
  • submit a comment on Instagram posts using jQuery or pure javascript
  • In Bootstrap 3's table-responsive when below breakpoint dropdown menus can't be used, any
  • How to debug component/typescript code when running Protractor
  • How do I set the logging properties in a spring java configuration?
  • Synchronous Calls with jqGrid?
  • Allowing audio files in Spring MVC 3.0?
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How to warp text around image in iOS?
  • What is the best way to cache and reuse immutable singleton objects in Java?
  • customize soft keyboard key preview
  • Using Service Component Runtime
  • How to use FirstOrDefault inside Include
  • PHP Permalinks.. how to change?
  • media foundation H264 decoder not working properly
  • Running R's aov() mixed effects model from Python using rpy2
  • Access to a Matlab gui from the web
  • ReferenceError: TextEncoder is not defined