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

Reference highlighting doesn't work for some types from constructor expression #74803

Closed
Peter-Juhasz opened this issue Aug 19, 2024 · 11 comments
Labels

Comments

@Peter-Juhasz
Copy link

Version Used: 17.12.0 P1

Steps to Reproduce:

Look at how highlighting of references of FinishedStatus doesn't work if I select the symbol in a constructor expression, while it works if I select the type in a declaration expression:

Kepernyofelvetel.2024-08-19.175334.mp4
[JsonPolymorphic]
[JsonDerivedType(typeof(FinishedStatus), "Jobs.Finished")]
public abstract record class JobStatusUpdate(DateTimeOffset Timestamp);

public record class FinishedStatus(DateTimeOffset Timestamp) : JobStatusUpdate(Timestamp);

Unfortunately, I could not narrow down the context in which it doesn't work. But it never picks up this type (or any of its siblings - inherited from JobStatusUpdate) in any file in the whole solution.

Notes:

  • Code compiles successfully
  • Go To Definition and Find All References work fine

Diagnostic Id:
N/A

Expected Behavior:
It finds and highlights references from all starting points.

Actual Behavior:
It does not highlight references from a constructor expression.

@Rekkonnect
Copy link
Contributor

I cannot reproduce this in 17.12.0 P3

@Peter-Juhasz
Copy link
Author

Peter-Juhasz commented Oct 18, 2024

It is still broken for me (in 17.12 P3):

20241018-1824-11.4051449.mp4

@Rekkonnect
Copy link
Contributor

Your FailedStatus seems to be in another file, right? That could also be it.

@Peter-Juhasz
Copy link
Author

Yes, and you nailed it! Once I move them to the same file, it finds the references both ways.

@Rekkonnect
Copy link
Contributor

I tried to reproduce this in both 17.11, 17.12 P3 and the current main (7d58a7f), but could not see this happen to me. Wrote the exact code you show in the videos, added a partial Extensions class with 2 partial declarations in separate files, used the constructor in multiple files and it still works; the identifiers are properly highlighted, find all references finds all the constructors and go to definition also works.

This is a very strange case. Perhaps try restarting VS, using another VS color theme? Maybe post some more code to provide critical context that could be missing?

@CyrusNajmabadi
Copy link
Member

I cannot repro this either. Please support a repro project if you are still seeing this.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 26, 2024
@Peter-Juhasz
Copy link
Author

I can still do in a large project:

20241126-0848-57.8840407.mp4

But unfortunately, if I copy the same files in the same structure into a small console app, it works fine. So, my guess is it may be related to some timing/cancellation issues, perhaps it finishes quickly in a small project, but takes more time in a large project to calculate the references and gets cancelled meanwhile?

I've seen other issues (Go to definition, Quick info, ..) were closed by fixing an issue related to cancellation (thank you, I appreciate the effort!), maybe this one has the same root cause, or already fixed by those changes.

@Rekkonnect
Copy link
Contributor

I confirm the above; I've also seen this here and there on larger projects and slower machines, while it always seems to work fine in other cases, including tests

@CyrusNajmabadi
Copy link
Member

Does this repro for you on 17.13 builds?

@Peter-Juhasz
Copy link
Author

Peter-Juhasz commented Nov 26, 2024

Yes, I'm on VS 17.13.0 Preview 1.0, .NET 9.0.100 (and Intel i9-13900K with 64 GB RAM).

Total number of files: 979

Extension Files Lines
.cs 607 105985
.razor 135 24155
.cshtml 1 50

@Rekkonnect
Copy link
Contributor

@CyrusNajmabadi has #76097 fixed this?

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

3 participants