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

How to create generative providers with the new context based provided type API without error. #82

Closed
7sharp9 opened this issue Mar 9, 2016 · 11 comments
Labels

Comments

@7sharp9
Copy link
Member

7sharp9 commented Mar 9, 2016

Currently if I convert to the new API I get a:

Which seems to stem from assembly generator:

type ProvidedAssembly(assemblyFileName: string) = 
    let theTypes = ResizeArray<_>()
    let assemblyGenerator = AssemblyGenerator(assemblyFileName)
    let assemblyLazy = 
        lazy 
            assemblyGenerator.Generate(theTypes |> Seq.toList)

If would be great if the provided types API was able to support unchecked quotation for generative types as they have the same issues relating to reflection based loading etc.

@7sharp9
Copy link
Member Author

7sharp9 commented Mar 9, 2016

@dsyme Any advice on getting this to work on generative would be greatly received :-)

@dsyme
Copy link
Contributor

dsyme commented Apr 4, 2016

@7sharp9 Can you give a detailed repro for this please, with a link to a sample project or PR, and details of operating system etc.?

@7sharp9
Copy link
Member Author

7sharp9 commented Apr 4, 2016

I don't currently have a public repro but Ill see about making one.

@7sharp9
Copy link
Member Author

7sharp9 commented Apr 4, 2016

Ok, repro repo is here:
https://github.com/7sharp9/ContextBasedGenerative

Error

This code used to work fine before using the ctxt to add the various provided entities.

I used the very lasted code that was committed here this morning.

@sergey-tihon
Copy link
Member

@7sharp9 Could you please add this as a test to this repo?
Seems like I also need working sample of this.

@7sharp9
Copy link
Member Author

7sharp9 commented Apr 7, 2016

@sergey-tihon Thats the thing, it doesn't work at all yet for generatives.

@7sharp9
Copy link
Member Author

7sharp9 commented Apr 13, 2017

Ok this has been here for a year now, is the context API going to be the way forward or forever experimental? //cc @dsyme

@AviAvni
Copy link

AviAvni commented Aug 16, 2017

@7sharp9 @dsyme I debugged the repro what I found is that when using types like obj or string as base type like in
https://github.com/7sharp9/ContextBasedGenerative/blob/master/ContextBasedGenerative/TypeProvider.fs#L20

then this type is converted using this function:
https://github.com/fsprojects/FSharp.TypeProviders.StarterPack/blob/master/src/ProvidedTypesContext.fs#L149
to ContextTypeDefinition that not implement Module property and other type functionality which needed for
https://github.com/fsprojects/FSharp.TypeProviders.StarterPack/blob/master/src/ProvidedTypes.fs#L2562

when I changed the implementation of replaceType to return the same type for types defined in mscorlib
then the code in the test compiled and work correctly

then I tried to understand why this convert is needed for types that is not provided types still didn't understand why it's needed

I tried also to make the base type of the provider a type that i decleared in the ContextBasedGenerative
I had the same problem and when I changed this line:
https://github.com/fsprojects/FSharp.TypeProviders.StarterPack/blob/master/src/ProvidedTypesContext.fs#L175
to return t it also work in the test and the base type was correct one from the ContextBasedGenerative assembly

this is the summary for what I found till now
what do you think?
what I can do to help more?

@dsyme
Copy link
Contributor

dsyme commented Oct 7, 2017

I've added a comment about this here #133 (comment)

I think we need to move to a different IL writer for generative providers authored using this SDK - that is needed for .NET Core/.NET Standard in any case. I'm quite keen to minimize binary dependencies, so I'm inclined to use the Abstract IL writer from the F# compiler, since it can be just a single file (like our assembly reader), but I need to think about it.

@AviAvni
Copy link

AviAvni commented Oct 9, 2017

@dsyme
Copy link
Contributor

dsyme commented Nov 2, 2017

@AviAvni Thanks, this is fixed through the updated SDK

@dsyme dsyme closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants