Skip to content

Getting nothing from GetAllUsesOfAllSymbols() when using DocumentSource.Custom #15960

Closed

Description

@dawedawe

Hey everyone hello @0101,

we're facing an issue with the checker API:

In tests, the DocumentSource.Custom is often used when creating an FSharpChecker.
Doing something like:

let checkProjectResults = checker.ParseAndCheckProject(opts) |> Async.RunSynchronously
let allSymbolUses = checkProjectResults.GetAllUsesOfAllSymbols()

yields no results in allSymbolUses.

It seems to be a caching issue, as the usage of DocumentSource.Custom means that useChangeNotifications will be set to true in the builder which affects the slots.

A workaround is calling FSharpChecker.NotifyFileChanged for the files in the project before calling ParseAndCheckProject().

Is this really the expected behaviour when using DocumentSource.Custom or something we should document?

Activity

  1. added this to the Backlog milestone on Sep 11, 2023
  2. 0101 commented on Sep 11, 2023

    @0101
    Contributor

    Hey, so this happens when you check the project for the first time? In general you do need to call NotifyFileChanged when a file has changed when using DocumentSource.Custom, which is documented. But it's suspicious if you get empty symbol uses. Maybe there's a bug with IncrementalBuilder state initialization or something. I'll have a look.

  3. dawedawe commented on Sep 11, 2023

    @dawedawe
    ContributorAuthor

    Hey, so this happens when you check the project for the first time?

    Well, calling ParseAndCheckProject multiple times before the first call to GetAllUsesOfAllSymbols makes no difference in this case. The result of GetAllUsesOfAllSymbols is still empty.

  4. 0101 commented on Sep 12, 2023

    @0101
    Contributor

    After some experimentation, setting Notified = true in the initial state seems to fix it. But I can't yet tell why exactly and if it can have some negative consequences.

    @majocha Do you remember anything about this by any chance?

  5. majocha commented on Sep 12, 2023

    @majocha
    Contributor

    @majocha Do you remember anything about this by any chance?

    Probably this will force checking of every file from the start. I'll try to look and refresh my memory later today.

  6. 0101 commented on Sep 12, 2023

    @0101
    Contributor

    Here's a test for it: #15966

    The Activity traces look the same regardless of initially setting Notified to true or false. Except in the first case symbols are present and in the second one they aren't.

  7. majocha commented on Sep 12, 2023

    @majocha
    Contributor

    @0101 sounds like a good fix :)

    For useChangeNotifications=false the indication that the a slot has never been checked is kinda hidden here:

    Stamp = DateTime.MinValue

    Notified = true should give the same behavior when useChangeNotifications=true. I wonder how and why this worked at all before 😅.

  8. 0101 commented on Sep 13, 2023

    @0101
    Contributor

    Yeah it's a bit strange because everything else seems to work fine. I thought maybe this was somehow causing the bound models to be invalidated so we can't access tcExtras even though it must have been produced by the full project check. Anyway, let's make the change and see what happens :)

  9. self-assigned this
    on Sep 13, 2023
  10. added
    Area-Compiler-Service
    on Sep 13, 2023
  11. modified the milestones: Backlog, September-2023 on Sep 13, 2023
  12. dawedawe commented on Sep 18, 2023

    @dawedawe
    ContributorAuthor

    Thanks guys ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-Compiler-ServiceBugNeeds-Triage

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions