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

In-memory cross-project reference not working for project using a generative type provider #11771

Closed
jkone27 opened this issue Jul 2, 2021 · 5 comments
Labels
Area-LangService-API Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression

Comments

@jkone27
Copy link
Contributor

jkone27 commented Jul 2, 2021

When I use VS Build has 0 errors, but VS ide says there is errors.. this repo should allow to reproduce https://github.com/jkone27/test-broken

Workaround

Tools -> Options -> Text Editor -> F# -> Performance -> Turn off "Enable in-memory cross project references"

Details

I am on win10 and vs2019 (and vs2020 also affected)

e..g in another repo

image

@dsyme
Copy link
Contributor

dsyme commented Jul 6, 2021

I can confirm this is a bug (haven't been able to check with main as yet, only with 16.10.3)

It goes away when you turn off in-memory cross project references

It is something to do with in-memory reference to a project using type providers

Workaround: Tools -> Options -> Text Editor -> F# -> Performance -> Turn off "Enable in-memory cross project references"

@dsyme dsyme changed the title FS0039 error In-memory cross-project reference not working for project using a generative type provider Jul 6, 2021
@dsyme
Copy link
Contributor

dsyme commented Jul 6, 2021

@jkone27 Did you only experience this with repos that involve the Swagger type provider? If you have any other repros please include them

@dsyme
Copy link
Contributor

dsyme commented Jul 6, 2021

@TIHan I'm recalling the details now. In brief, in-memory cross-project references simply don't work for projects involving generative type providers. However they should be implicitly disabled, that's what this PR was about: #3236

I suspect this implicit disablement is no longer functioning. The relevant code is still there:

                        if tcState.CreatesGeneratedProvidedTypes || hasTypeProviderAssemblyAttrib then
                            None
                        else
                            Some  (RawFSharpAssemblyDataBackedByLanguageService (tcConfig, tcGlobals, generatedCcu, outfile, topAttrs, assemblyName, ilAssemRef) :> IRawFSharpAssemblyData)

Perhaps if this kicks in the project assembly reference is now being completely dropped on the floor.

I'll look into it and debug further

@dsyme
Copy link
Contributor

dsyme commented Jul 6, 2021

This looks like the problem:

        // If we have a project reference but did not get any valid contents,
        //     just return None and do not attempt to read elsewhere.
        if contentsOpt.IsNone && r.ProjectReference.IsSome then
            return None
        else

It is valid to get None in this case, and we should revert to the on-disk DLL if it exists, as a known limitation of the tooling.

Introduced here: #11485

I'll work on a fix and review why the testing added here: https://github.com/dotnet/fsharp/pull/3236/files#diff-07f76d461e78df1feb8cfc153fac5455336aba8964f51656905c041187a4fefdR777 didn't prevent this regression

@dsyme dsyme added Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression labels Jul 6, 2021
@dsyme
Copy link
Contributor

dsyme commented Jul 7, 2021

Fixed by #11791

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-API Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Projects
None yet
Development

No branches or pull requests

3 participants