CSV Type provider - f#

I am trying to find a easy example or introduction to a CSV Type provider. So I followed this link to help me get started. Now I have a Visual Studio 2012 students edition and while documentation says that F# 3.0 has the CSV type provider I am not able to find it. So I am trying to use a type provider for a local CSV File. What I see is that the CSV TypeProvider mentioned does not exist at all. Since the given examples don't really compile I looked around and used something like this to load the oData services :
#r "FSharp.Data.TypeProviders"
///loading a stackoverflow odata type provider
type stackOverflow = Microsoft.FSharp.Data.TypeProviders.ODataService<"http://data.stackexchange.com/stackoverflow/atom">
So this is a bit different from what is mentioned in the example page above. I am not able to see the csv type provider. I use the Visual Studio IDE to list the type providers and csv is not listed. I tried updating the packages using nuget and this still persists. Can anyone point the right documentation on how to work with a csv type provider and also the right updated links where a simple example could be found?

FSharp.Data isn't a built-in library, so you either need to use nuget or manually download the package. See here for more information on where to get it (and how to use it).
If you manually download the project you can put it wherever you want and then simply use a file path to reference it with #r. For a path relative to your project, use the __SOURCE_DIRECTORY__ symbol, otherwise you can simply use the absolute file path of the .dll.
After referencing the dll, you still need to open the namespace, so you need to have open FSharp.Data after you reference the dll.

Alright so this is what I did. I used Nuget to manage references and I installed the FSharp.Data and FSharp.Data.TypeProviders and like #mydogisbox mentioned I then use the open FSharp.Data to load the csv files i.e.
open FSharp.Data.Csv
While this works if I use Nuget, it doesn't work otherwise. So have to figure out how to do that. For now this should suffice I guess.

Related

How do I access FSharp.Data.JsonExtensions?

Sorry if this question is a bit unclear. It was the best I could do in my state of confusion about packages in F# 4.0.
The book Expert F# 4.0 by Don Syme, Adam Granicz, and Antonio Cisternino contains code that processes JSON data. The code starts with
open FSharp.Data
open FSharp.Data.JsonExtensions
I have FSharp.Data installed in Visual Studio. Still, the word "JsonExtensions" gets red squiggles under it and the rest of the code does not compile.
Going to Add References in the Solution Explorer I did not find a package FSharp.Data.JsonExtensions. I also looked under NuGet and found no package FSharp.Data.JsonExtensions. There is documentation for JsonExtensions
which suggests it is a module. However, using the dot in Visual Studio it does not appear under FSharp.Data. (There is only one entry: Unit Systems)
How can I make the code in this module available so I can run the code in the book?
This happens because actually you don't have FSharp.Data installed (So Foggy is right above). There is an FSharp.Data namespace but you need to nuget the package to be able to use it. So go to Tools | Nuget Package Manager | Manage Nuget Packages for Solution and download the latest and greatest FSharp.Data. This will automatically add it to your references file in VS:
See:
Now you can use it:
If you are using it from an .fsx script make sure to reference it with #r
#r #"..\packages\FSharp.Data.2.3.2\lib\net40\FSharp.Data.dll"
In that case you can just right-click on the References (after nugetting) and VS will generate you the path:
If you don't see Send to F# Interactive I strongly suggest you install the Visual F# Power Tools.
You can explore other ways of accessing/serializing JSON files: there is the JSON type provider, Newtonsoft JSON, FSharplu, Chiron, and FSPickler.

FunScript: How to access TypeScript.Api<...>

I'm getting started with FunScript with a working example. Using Nuget to add the needed libraries, it works well.
In watching a 2013 video on channel9, they are making use of TypeScript.Api<...> to load types from typescript definition files.
I'm however unable to find this type provider anywhere.
Where is it located?
I realized that a good number of the type definitions have been compiled into libraries and available on nuget but I can't really use this since some of the code will be local typescript definition files.
The questions therefore are
Where is the TypeScript.Api<...> type provider?
If it is not available or the best way to use typescript definition, what other options exists.
As Thomas said, the type provider was removed mainly because it couldn't generate generic types, but the idea is to bring it back at some point.
For the moment, though not ideal, you can generate your own bindings following these steps.
Download or clone Funscript repository
git clone https://github.com/ZachBray/FunScript
Build the project
cd FunScript
build.cmd
This needs to be improved but for now you need to zip the .d.ts files you want to convert and then:
cd build\TypeScript
bin\FunScript.TypeScript.exe C:\Path\to\typedefinitions.zip
cd Output
Please note the first time you build the definitions it may take several minutes. Once it's done in the output folder you'll find the compiled .dll libraries with the bindings.
Also, while you're at it. It's better if you use the FunScript version you just build into build\main\bin, as it will probably be more updated than the nuget package.
Good luck and have fun(script)!
There were a bunch of changes in FunScript, so the TypeScript.Api<...> type provider is no longer the recommended way of calling JavaScript libraries from FunScript.
Instead, the bindings for JavaScript libraries are pre-generated and you can find them as packages on NuGet, if you search for the FunScript tag (NuGet search is not very good, so you may need to go through a number of pages to find the one you need...).
If you want to use a local TypeScript definition, then you'll need to run the command line tool to generate the bindings. The F# Atom plugin does this in the build script, so looking there is a good place to start. It has a local copy of various TypeScript bindings in the typings folder (together with the FunScript binaries needed to process them).
I liked the type provider approach much better, but sadly, type providers are somewhat restricted in what kind of types they can provide, so it wasn't all that powerful...

How to create simple Wix setup project

We have a client/server application which includes a Windows Service and a Winform client tool. I've managed to create a Wix project in Visual Studio (2010, using the wix 3.5 toolset). I'm using the "harvest" feature on the references instead of specifying every file, because there are many library projects involved.
Problems I'm trying to figure out:
How to include referenced DLLs? Some are in the GAC, some are in a relative path within the workspace. I assume I could list each file explicitly but it seems like there should be a way for Wix to autodetect them.
How to install the service while "harvest" is enabled. All the examples I've seen require adding an explicit element with KeyPath=true. However this doesn't work with the harvest=true setting.
I realize that the harvest functionality might be a convenience which is not feasible when there are more complex things going on. Should I give up on harvesting and just try to specify each file explicitly?
Most of the examples I've seen on Wix have been just snippets of xml files. Is there anywhere I can find complete real-world examples of installing services other non-trivial setup features?
Use WixEdit. http://wixedit.sourceforge.net/
It's very easy to import an entire folder using it.
Also, check out the great WiX tutorial here: http://www.tramontana.co.hu/wix/
5.4 Services Rendered
Services can be installed and started automatically.
http://wix.tramontana.co.hu/tutorial/net-and-net/services-rendered
For even more information, check out more WiX documentation here: http://wixtoolset.org/documentation/manual

windbg: version of loaded assemblies

does anybody know how to figure out the assembly versions (not file versions) of loaded assemblies if I have a full memory dump?
Suppose I have a full dump of the .net process and I found two assemblies with the same name loaded in one AppDomain. I need to know what versions those assemblies have.
The SOS commands !dumpmodule, !dumpassembly and !dumpdomain do not provide that kind of information or I just missed something.
Thank you in advance.
You could try the !SaveModule SOS command. This takes the start address of an assembly and creates a new file (the name of which is given by you) to save the contents of the assembly. You could then use something like .NET Refletor to open the file, and it might give you the .NET version somewhere in there. This SO question has some details on that:
How to find out which version of the .NET Framework an executable needs to run?
As for the !SaveModule command, here's a blog article that describes how to use it:
http://blogs.msdn.com/b/tess/archive/2006/05/18/601002.aspx?PageIndex=2

Register applications via Registry table rather than TLBs

We register the capabilities of Delphi applications using TLB files. However, from reading MSDN documentation, "Installation package authors are strongly advised against using the TypeLib table. Instead, they should register type libraries by using the Registry table". Does anyone have any advice on how to do this in a 'Delphi' way for Windows 7?
It means you would need to figure out what registry entries to add to register the tlb. This explains what needs to be done. You could also use a tool like REGCAP.EXE which comes with Visual and generates a .reg file. If you use WiX to build your msi you could use tools like tallow and heat to let them generate the wix files for you.
I'm going to answer my own question! This is a duplicate of this question, which seems to have the answer I needed (just in a different language that I would normally use).

Resources