You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring a private field in a razor.cs file, and bind it by ref in the related razor file, sonar marks it as not assigned. Sonar should check the related razor file for S3459 as well.
Repro steps
Create a Blazor component with two files:
MyBlazorComponent.razor
<Modal@ref="@_myModalRef"></Modal>
MyBlazorComponent.razor.cs
publicpartialclassMyBlazorComponent{privateModal_myModalRef;// Sonar marks this field as not assigned}
Expected behavior
Recognize that the field actually is being assigned by ref in razor file.
Actual behavior
Mark every occurrence as false positive, or disable rule csharpsquid:S3459 for **/*.razor.cs completely.
Probably not using code in separate *razor.cs file but declare the private field in the razor file itself. Did not test that.
Known workarounds
Please provide a description of any known workarounds.
Related information
C# 12
Rider 2023.3.2
.Net 8
SonarLint plugin 10.2.1.77304 connected to SonarCloud
Windows 11
The text was updated successfully, but these errors were encountered:
martin-strecker-sonarsource
changed the title
Fix S3459 FP: Unassigned members should be removed -> Does not recognize bindings from razor files / partial Blazor components
Fix S3459 FP: Support @ref bindings in razor files / partial Blazor components
Jun 4, 2024
Description
When declaring a private field in a razor.cs file, and bind it by ref in the related razor file, sonar marks it as not assigned. Sonar should check the related razor file for S3459 as well.
Repro steps
Create a Blazor component with two files:
MyBlazorComponent.razor
MyBlazorComponent.razor.cs
Expected behavior
Recognize that the field actually is being assigned by ref in razor file.
Actual behavior
Mark every occurrence as false positive, or disable rule
csharpsquid:S3459
for**/*.razor.cs
completely.Probably not using code in separate *razor.cs file but declare the private field in the razor file itself. Did not test that.
Known workarounds
Please provide a description of any known workarounds.
Related information
The text was updated successfully, but these errors were encountered: