Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative paths and external loading on library usage #1520

Open
Thorium opened this issue Dec 11, 2024 · 1 comment
Open

Relative paths and external loading on library usage #1520

Thorium opened this issue Dec 11, 2024 · 1 comment

Comments

@Thorium
Copy link
Member

Thorium commented Dec 11, 2024

I would like to keep 3rd party data-structures of JSON / XML files (samples) in separate files, so that e.g. the intellisense of those files is easily checked.

So I like using F# data with, great:

// Library 1 (a dll):
FSharp.Data.JsonProvider<"json-samples/whateverService.json", SampleIsList = true>
//...logic to use the types.

// Root project (e.g. myprogram.exe): Project reference (or NuGet) to Library 1.

However, when multiple F# projects exist, e.g., via separate NuGet libraries or separate F# dlls, it's really unclear (on compile-time) what the relative path is pointing to.

So it seems this "json-samples"-folder should be included in all the root level programs, while my expectation would be that it only points to the library of actual source code above (Library1). FSharp.Data is a generative provider. Wouldn't it be enough to generate the types on the compilation of Library1, then embed them there, and never spend resources to regenerate them again (on design-time and compilation of "root programs")?

@Thorium
Copy link
Member Author

Thorium commented Jan 10, 2025

Another question on usage in external libraries: I don't want user of my library to suffer the high memory load of VS IDE when using a typeprovider. So would it help to try to hide FSharp.Data provider to internal by something like this:

type internal serviceResponseRaw = FSharp.Data.JsonProvider<"...", SampleIsList = true>
type serviceResponse = serviceResponseRaw.Root
let myPublicLibraryMethod() : serviceResponse = 
   serviceResponseRaw.Parse(...) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant