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
We get a false positive for Unused private types or members should be removed
Repro steps
We have a private function that is called from the Dispose function that is in the designer file
namespaceWindowsFormsApp3{publicpartialclassForm1:Form{publicForm1(){
InitializeComponent();}privatevoidDoMoreDisposing(){}}}namespaceWindowsFormsApp3{partialclassForm1{/// <summary>/// Required designer variable./// </summary>private System.ComponentModel.IContainer components=null;/// <summary>/// Clean up any resources being used./// </summary>/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>protectedoverridevoidDispose(booldisposing){if(disposing&&(components!=null)){
components.Dispose();}
DoMoreDisposing();base.Dispose(disposing);}
#region Windows Form Designer generated code
/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>privatevoidInitializeComponent(){this.SuspendLayout();// // Form1// this.AutoScaleDimensions =new System.Drawing.SizeF(6F,13F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize =new System.Drawing.Size(800,450);this.Name ="Form1";this.Text ="Form1";this.ResumeLayout(false);}
#endregion
}}
Expected behavior
No warning
Actual behavior
Message S1144 Remove the unused private method 'DoMoreDisposing'.
Known workarounds
Move the dispose method or mark item as false positive
Related information
SonarC# Version 7.11.0.8083
Visual Studio Version 2017
If running through the Scanner for MSBuild, its version 4.5.0.1761
Reproduced in VS2019 with SonarAnalyzer.CSharp 7.11.0.8083
The text was updated successfully, but these errors were encountered:
Evangelink
changed the title
False positive for S1144: Unused private types or members should be removed
Fix S1144: False Positive when private member is only used in a generated file
Mar 6, 2019
Description
We get a false positive for Unused private types or members should be removed
Repro steps
We have a private function that is called from the Dispose function that is in the designer file
Expected behavior
No warning
Actual behavior
Message S1144 Remove the unused private method 'DoMoreDisposing'.
Known workarounds
Move the dispose method or mark item as false positive
Related information
Reproduced in VS2019 with SonarAnalyzer.CSharp 7.11.0.8083
The text was updated successfully, but these errors were encountered: