Blazor (razor page) with @ref to field produce a S4487: Remove this unread private field

Hi, I have a page where I have some components with a reference to a backfield.
@ref="_areaChart"

and in my code I have private ApexChart<ChartData>? _areaChart

Yet anytime I build, clean, rebuild, close Visual Studio and rebuild, the compiler tells me I don’t use the _areaChart field and it should be removed.

See the screenshot of my code below :

error S4487: Remove this unread private field ‘_areaChart’ or refactor the code to use its value. (C# static code analysis)

Is it a bug of SonarSource or Visual Studio ?
Right now, I have a fake method that use the private field just to trick the sonarsource.
(_areaChart = _areaChart;)

  • Operating system: Windows 11
  • IDE name and flavor/env: Visual Studio 2022 17.14

Might be linked to There is an issue with csharpsquid:S1144 (unused code detection) with razor pages - SonarQube for IDE / IntelliJ Platform - Sonar Community

Hello @nk54fr and I’m sorry for the delay.

this seems like a FP similar to the one you linked, however in this case it’s visual studio and not rider - so the mechanics are different.

Could you please provide me with a reproducer?

Also when does this occur? With SQ for IDE right? Which version?
In case you use SQ Server or SQ Cloud, does it appear also there?

Thanks