Repro:
public class TestCase
{
public Boolean MyFieldIsFour(MyRecord myRecord)
{
return myRecord.MyField == 4;
}
}
public record MyRecord(int MyField);
Right click int MyField
and choose Find All References
.
Visual Studio can't find any references to MyField
. I would have expected it to find the reference at myRecord.MyField
. If MyRecord
is changed to a class
then Visual Studio has no problems finding the reference as expected.
Is this a bug in Visual Studio? How can I actually find references now with record
s?
The Find All References command is available on the context (right-click) menu of the element you want to find references to. Or, if you are a keyboard user, press Shift + F12.
If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference. For more information, see How to: Add or remove references.
This is a bug (or not implemented feature if you want call it that way) in Roslyn.
The semantics around record
s is a mess. See this feedback, this issue, this issue, this issue, this issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With