fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
813 stars 287 forks source link

Use AddDefinitionLocation in the type providers when using a file in the sample #52

Open ovatsus opened 11 years ago

ovatsus commented 11 years ago

So when pressing F12 in VisualStudio on a generated property, it opens up the sample csv/xml/json in the right place. See http://msdn.microsoft.com/en-gb/library/hh361034.aspx for an example

ovatsus commented 9 years ago

@taylorwood want to pick this one?

taylorwood commented 9 years ago

I'll try to do it in CsvGenerator.fs first, then we can see if I'm on the right track.

taylorwood commented 9 years ago

I'm trying to track the offset of each separator of the first row of the file, as it is being parsed in CsvReader.readCsvFile. My first attempt incremented a mutable offset variable while Read()ing, and it felt clumsy, but the only other approach I imagined would be bubbling an offset arg through the recursive read functions which doesn't seem all that elegant either; especially considering that it only needs to be done for the first row. I'm assuming that it'd need to support line breaks in first row column headers too, so line numbers would also need to be tracked?

This would seem so trivial in an imperative style, but a more elegant functional solution is eluding me! I'll keep playing with it in my spare time, but I'm open to suggestions.

dsyme commented 9 years ago

@ovatsus @taylorwood - Speaking of which, it should really be possible to modify the Xamarin and Visual Studio F# Tools to open a URL and not just a document. It would be so cool to be able to "go to definition" to a web page you're screen scraping :) . I'm not quite sure where the actual point is in the Visual F# Tools or Visual Studio where a file is required - it may be in the Visual F# Tools language service components.

Let me know if you'd like more info on where to look to implement this "go to definition take you to a URL" feature in the Visual F# Tools as I think it would work particularly well with FSharp.Data. I'm pretty sure it would require a diff to the Visual F# Tools themslves though.

ovatsus commented 9 years ago

I'm ok with having mutable variables when it makes your life easier