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

InvalidCastException in ValueTracking #57100

Closed
yyjdelete opened this issue Oct 12, 2021 · 0 comments · Fixed by #57727
Closed

InvalidCastException in ValueTracking #57100

yyjdelete opened this issue Oct 12, 2021 · 0 comments · Fixed by #57727
Assignees
Milestone

Comments

@yyjdelete
Copy link

Version Used:
VS2022 Version 17.0.0 Preview 4.1

Steps to Reproduce:

        public int this[string key] => 0;
  1. Right click, and click Track Value Source with key

Expected Behavior:

Actual Behavior:

System.InvalidCastException: Cannot cast an object of type "Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.PropertySymbol" to type "Microsoft.CodeAnalysis.IMethodSymbol".
      at Microsoft.CodeAnalysis.ValueTracking.ValueTracker.<TrackParameterSymbolAsync>d__4.MoveNext()
      at Microsoft.CodeAnalysis.ValueTracking.ValueTracker.<TrackValueSourceAsync>d__1.MoveNext()
      at Microsoft.CodeAnalysis.Remote.RemoteValueTrackingService.<>c__DisplayClass3_0.<<TrackValueSourceAsync>b__0>d.MoveNext()
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunServiceImplAsync>d__12`1.MoveNext()
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 12, 2021
@yyjdelete yyjdelete changed the title InvalidCastException in InvalidCastException in ValueTracking Oct 12, 2021
@jinujoseph jinujoseph added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 13, 2021
@jinujoseph jinujoseph added this to the 17.1 milestone Oct 13, 2021
ryzngard added a commit that referenced this issue Nov 16, 2021
Index values weren't properly handled previously, and it was assumed all parameters existed in a method. In reality some exist in properties. Who knew!??!

No need to worry about the cast, symbol finder will do the right thing. Code does need to be updated to handle the fact that we want to track potentially two things with index: the argument passed in as the index in callsites, and potentially the item being indexed to. Update the FindReferencesProgress to handle references for index specifically.

Fixes #57100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants