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

Build with embedded resource broke after upgrade from 3.0.0 to 3.0.1 #1255

Closed
Karamell opened this issue Apr 1, 2019 · 18 comments · Fixed by fsprojects/FSharp.TypeProviders.SDK#324

Comments

@Karamell
Copy link
Contributor

Karamell commented Apr 1, 2019

I get an error message if I upgrade JsonProvider from 3.0.0 to 3.0.1:

Error:

error FS3033: The type provider 'ProviderImplementation.JsonProvider' reported an error: The operation 'reading manifest resource %s' on item 'lib.file1.json' should not be called on provided type, member or parameter of type 'ProviderImplementation.ProvidedTypes.TargetAssembly'. Stack trace:
   at System.Environment.get_StackTrace()
   at ProviderImplementation.ProvidedTypes.Utils.notRequired[a,b](a this, String opname, String item) in C:\Git\FSharp.Data\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\ProvidedTypes.fs:line 169
   at ProviderImplementation.ProviderHelpers.readResource(DisposableTypeProviderForNamespaces tp, String resourceName) in C:\Git\FSharp.Data\src\CommonProviderImplementation\Helpers.fs:line 177
   at ProviderImplementation.ProviderHelpers.parseTextAtDesignTime@198.Invoke(IDisposable _arg1) in C:\Git\FSharp.Data\src\CommonProviderImplementation\Helpers.fs:line 210
   at Microsoft.FSharp.Core.Operators.Using[T,TResult](T resource, FSharpFunc`2 action)
   at ProviderImplementation.ProviderHelpers.generateType@368.Invoke(Unit unitVar0) in C:\Git\FSharp.Data\src\CommonProviderImplementation\Helpers.fs:line 377
   at ProviderImplementation.ProviderHelpers.getOrCreateProvidedType@293-3.Invoke(IDisposable _arg1) in C:\Git\FSharp.Data\src\CommonProviderImplementation\Helpers.fs:line 341
   at Microsoft.FSharp.Core.Operators.Using[T,TResult](T resource, FSharpFunc`2 action)
   at <StartupCode$FSharp-Data-DesignTime>.$ProvidedTypes.clo@9061-164.Invoke(FSharpFunc`2 f, String s, Object[] p) in C:\Git\FSharp.Data\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\ProvidedTypes.fs:line 9063
   at ProviderImplementation.ProvidedTypes.TypeProviderForNamespaces.Microsoft-FSharp-Core-CompilerServices-ITypeProvider-ApplyStaticArguments(Type ty, String[] typePathAfterArguments, Object[] objs) in C:\Git\FSharp.Data\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\ProvidedTypes.fs:line 14787
   at Microsoft.FSharp.Compiler.ExtensionTyping.TryApplyProvidedType@1165-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range)
   at Microsoft.FSharp.Compiler.Tainted`1.PApplyWithProvider[U](FSharpFunc`2 f, range range)
   at Microsoft.FSharp.Compiler.ExtensionTyping.TryApplyProvidedType(Tainted`1 typeBeforeArguments, FSharpOption`1 optGeneratedTypePath, Object[] staticArgs, range m)
   at Microsoft.FSharp.Compiler.ExtensionTyping.TryLinkProvidedType(Tainted`1 resolver, String[] moduleOrNamespace, String typeLogicalName, range range)
   at Microsoft.FSharp.Compiler.Tast.matched@3101.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at Microsoft.FSharp.Compiler.Tast.tryResolvePrefix@3097(CcuThunk ccu, String[] path, Int32 i, Entity entity, FSharpList`1 resolvers, ResolutionEnvironment resolutionEnvironment, Int32 j)
   at Microsoft.FSharp.Compiler.Tast.tryResolvePrefixes@3135(CcuThunk ccu, String[] path, Int32 i, Entity entity, FSharpList`1 resolvers, ResolutionEnvironment resolutionEnvironment, Int32 j)
   at Microsoft.FSharp.Compiler.Tast.NonLocalEntityRef.TryDerefEntityPathViaProvidedType(CcuThunk ccu, String[] path, Int32 i, Entity entity)
   at Microsoft.FSharp.Compiler.Tast.NonLocalEntityRef.TryDerefEntityPath(CcuThunk ccu, String[] path, Int32 i, Entity entity)
   at Microsoft.FSharp.Compiler.Tast.NonLocalEntityRef.TryDeref(Boolean canError)
   at Microsoft.FSharp.Compiler.Tast.EntityRef.get_Deref()
   at Microsoft.FSharp.Compiler.Tastops.stripTyEqnsA(TcGlobals g, Boolean canShortcut, TType ty)
   at Microsoft.FSharp.Compiler.Tastops.extensionInfoOfTy(TcGlobals g, TType ty)
   at Microsoft.FSharp.Compiler.Tastops.metadataOfTy(TcGlobals g, TType ty)
   at Microsoft.FSharp.Compiler.Tastops.isClassTy(TcGlobals g, TType ty)
   at Microsoft.FSharp.Compiler.NameResolution.AddPartsOfTyconRefToNameEnv(BulkAdd bulkAddMode, Boolean ownDefinition, TcGlobals g, ImportMap amap, range m, NameResolutionEnv nenv, EntityRef tcref)
   at Microsoft.FSharp.Compiler.NameResolution.env@702-6.Invoke(NameResolutionEnv nenv, EntityRef tcref)
   at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list)
   at Microsoft.FSharp.Compiler.NameResolution.AddTyconRefsToNameEnv(BulkAdd bulkAddMode, Boolean ownDefinition, TcGlobals g, ImportMap amap, range m, Boolean root, NameResolutionEnv nenv, FSharpList`1 tcrefs)
   at Microsoft.FSharp.Compiler.NameResolution.AddModuleOrNamespaceContentsToNameEnv(TcGlobals g, ImportMap amap, AccessorDomain ad, range m, Boolean root, NameResolutionEnv nenv, EntityRef modref)
   at Microsoft.FSharp.Compiler.NameResolution.AddModulesAndNamespacesContentsToNameEnv@820.Invoke(EntityRef modref, NameResolutionEnv acc)
   at Microsoft.FSharp.Compiler.TypeChecker.OpenModulesOrNamespaces(TcResultsSink tcSink, TcGlobals g, ImportMap amap, range scopem, Boolean root, TcEnv env, FSharpList`1 mvvs, OpenDeclaration openDeclaration)
   at Microsoft.FSharp.Compiler.TypeChecker.TcOpenDecl(TcResultsSink tcSink, TcGlobals g, ImportMap amap, range m, range scopem, TcEnv env, FSharpList`1 longId)
   at Microsoft.FSharp.Compiler.TypeChecker.TcModuleOrNamespaceElementNonMutRec@16782-1.Invoke(Unit unitVar)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.catch@877-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.catch@877-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.catch@877-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.catch@877-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.bind@868-1.Invoke(CompilationThreadToken ctok)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.forceWhile[a](CompilationThreadToken ctok, FSharpFunc`2 check, Eventually`1 e)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.EventuallyModule.force[a](CompilationThreadToken ctok, Eventually`1 e)
   at Microsoft.FSharp.Compiler.CompileOps.TypeCheckOneInput(CompilationThreadToken ctok, FSharpFunc`2 checkForErrors, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, FSharpOption`1 prefixPathOpt, TcState tcState, ParsedInput inp)
   at Microsoft.FSharp.Compiler.CompileOps.TypeCheckClosedInputSet@5559.Invoke(TcState tcState, ParsedInput inp)
   at Microsoft.FSharp.Primitives.Basics.List.mapFoldToFreshConsTail[TResult,TState,T](FSharpList`1 cons, FSharpFunc`3 f, TState acc, FSharpList`1 xs)
   at Microsoft.FSharp.Primitives.Basics.List.mapFold[TState,T,TResult](FSharpFunc`2 f, TState acc, FSharpList`1 xs)
   at Microsoft.FSharp.Collections.ListModule.MapFold[T,TState,TResult](FSharpFunc`2 mapping, TState state, FSharpList`1 list)
   at Microsoft.FSharp.Compiler.CompileOps.TypeCheckClosedInputSet(CompilationThreadToken ctok, FSharpFunc`2 checkForErrors, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, FSharpOption`1 prefixPathOpt, TcState tcState, FSharpList`1 inputs)
   at Microsoft.FSharp.Compiler.Driver.TypeCheck(CompilationThreadToken ctok, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, ErrorLogger errorLogger, String assemblyName, NiceNameGenerator niceNameGen, TcEnv tcEnv0, FSharpList`1 inputs, Exiter exiter)
   at Microsoft.FSharp.Compiler.Driver.main0[a](a ctok, String[] argv, Resolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, ErrorLoggerProvider errorLoggerProvider, DisposablesTracker disposables)
   at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile(CompilationThreadToken ctok, String[] argv, Resolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, ErrorLoggerProvider loggerProvider, FSharpOption`1 tcImportsCapture, FSharpOption`1 dynamicAssemblyCreator)
   at Microsoft.FSharp.Compiler.Driver.mainCompile(CompilationThreadToken ctok, String[] argv, Resolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, ErrorLoggerProvider loggerProvider, FSharpOption`1 tcImportsCapture, FSharpOption`1 dynamicAssemblyCreator)
   at Microsoft.FSharp.Compiler.CommandLineMain.Driver.main(String[] argv)
   at Microsoft.FSharp.Compiler.CommandLineMain.main(String[] argv)

to reproduce:
Make an app.fsproj with a program.fs:

open lib
[<EntryPoint>]
let main argv =
    Say.json
    0

and reference a lib.fsproj with a lib.fs:

namespace lib
open FSharp.Data
type File1 = JsonProvider<"file1.json", EmbeddedResource="lib, lib.file1.json">
module Say =
    let json =
        printfn "app won't compile"

json file is not complicated:

{
  "hey": "Hai!"
}
@panesofglass
Copy link
Contributor

Confirmed.

@Karamell
Copy link
Contributor Author

The error is also in the 3.3.1 release.

Probably thrown in the SDK's GetManifestResourceStream: https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/b08fe13625b2ffc08529cb9350db8f86c6b3c537/src/ProvidedTypes.fs#L8028-L8033

Maybe it's possible to upcast the assembly before calling GetManifestResourceStream? here: https://github.com/fsharp/FSharp.Data/blob/2dc537153e38bc1c20c858e934fb007f64db0dc9/src/CommonProviderImplementation/Helpers.fs#L177

Tarmil added a commit to Tarmil/FSharp.Data that referenced this issue Jun 13, 2019
@Tarmil
Copy link

Tarmil commented Jun 13, 2019

I'm facing this issue too, added a repro test here: https://github.com/Tarmil/FSharp.Data/tree/embeddedresource-repro

I tried uncommenting the code in GetManifestResourceStream in ProvidedTypes.fs, and I end up with an empty sequence as getReader().ILModuleDef.Resources.Entries. @dsyme You made the change that commented this out, do you have any clues here?


Maybe it's possible to upcast the assembly before calling GetManifestResourceStream?

It will still call the overridden method.

Tarmil added a commit to Tarmil/FSharp.Data that referenced this issue Jun 13, 2019
Tarmil added a commit to Tarmil/FSharp.Data that referenced this issue Jun 13, 2019
Tarmil added a commit to Tarmil/FSharp.Data that referenced this issue Jun 13, 2019
@fpellet
Copy link
Contributor

fpellet commented Jul 4, 2019

I search the bad commit and it's d390cdd
update TPSDK of @dsyme

I try with the last version of TPSDK, and it's works !
I'll make pr after lunch :)

@fpellet
Copy link
Contributor

fpellet commented Jul 4, 2019

My bad, the latest version is broken too, I took a old version

@dsyme
Copy link
Contributor

dsyme commented Sep 18, 2019

See fsprojects/FSharp.TypeProviders.SDK#324 for a likely fix, it reinstates the code to read resources (at the cost of re-cracking the PR File, though I don't think that's significant)

@fpellet Any chance you could test this fix, or is it too tricky to do so?

@Tarmil
Copy link

Tarmil commented Sep 19, 2019

I can confirm that the issue is fixed with the latest TPSDK master in the repro test I linked above 👍

https://github.com/Tarmil/FSharp.Data/tree/embeddedresource-fixed

@dsyme dsyme reopened this Sep 24, 2019
@dsyme
Copy link
Contributor

dsyme commented Sep 24, 2019

Integrated latest TPSDK and released as 3.3.1 then 3.3.2

@dsyme dsyme closed this as completed Sep 24, 2019
@Karamell
Copy link
Contributor Author

Karamell commented Oct 9, 2019

Should this issue be resolved in 3.3.2? It still fails in my code.

dsyme added a commit that referenced this issue Oct 11, 2019
Fix issue #1255 : EmbeddedResource not working
@samritchie
Copy link

I’m seeing this same issue with the CsvProvider (on both 3.3.1 & 3.3.2) - The operation 'reading manifest resource %s' on item '{embedded resource name}' should not be called on provided type, member or parameter of type 'ProviderImplementation.ProvidedTypes.TargetAssembly'

@thekidwhousesabow
Copy link

JsonProvider in FSharp.Data 3.3.2 is still giving me this issue.
Repository with basic example: https://github.com/thekidwhousesabow/JsonProviderErrorExample

@fpellet
Copy link
Contributor

fpellet commented Dec 16, 2019

Hum, I think that the code is good, but nuget package is bad
The nuget package of 3.3.2 seems to be the same as 3.2.1
One person can check nuget content ? @thekidwhousesabow @samritchie @Karamell can you try this package nuget with your code source or build last version ?
FSharp.Data.3.3.3-beta.nupkg.zip

@champloo
Copy link

champloo commented Jan 4, 2020

@fpellet I've tried your package and built 3.3.2 from source again and they both work. The package from Nuget does not.

As you pointed out 3.3.1 and 3.3.2 Nuget packages contain the same binaries. Both happen to be identical to 3.2.4 as well. As of 3.3.1 the release branch (https://github.com/fsharp/FSharp.Data/commits/release) has only included the .nupkg file and not the binaries. The binaries commited in the release branch are still from 3.2.4. This appears to be a change in the release process. @dsyme could this be what is causing the wrong binaries to be released to Nuget?

@dsyme
Copy link
Contributor

dsyme commented Jan 7, 2020

@champloo I bumped the version, rebuilt master from clean and manually pushed a nuget for FSharp.Data 3.3.3. Could you check it out and see if it fixes your problems?

I tried a build Release for 3.3.4 but got a failure, I might not have set a github API key correctly.

@dsyme
Copy link
Contributor

dsyme commented Jan 7, 2020

OK I removed the whole "push binaries to release branch" thing as I don't see why we're releasing via any other mechanism but nuget. Github is not meant to be for binary releases....

@Karamell
Copy link
Contributor Author

Karamell commented Jan 9, 2020

I can confirm that nuget packet version 3.3.3 works for me. 3.3.2 does not work.

@champloo
Copy link

@dsyme 3.3.3 fixes the issues that I was having. Thank you.

@dsyme
Copy link
Contributor

dsyme commented Jan 22, 2020

3.3.3 fixes the issues that I was having. Thank you.

Thanks for confirming!

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

Successfully merging a pull request may close this issue.

8 participants