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
Rule S3963, as far as I understand by reading the code, raises an error as soon as there is a static constructor. That picks up much more cases than the "Initialize all 'static fields' inline and remove the 'static constructor'" description would suggest.
Repro steps
class Program
{
static Program()
{
System.Console.WriteLine("Not assigning a field");
}
}
Real life examples instead of a WriteLine: initialization of GUI component, static initialisation of a vendor's license, basically all sorts of void method calls with side effects.
The text was updated successfully, but these errors were encountered:
valhristov
changed the title
Rule S3963: False positive when static constructor does not assign any fields
Fix S3963: False positive when static constructor does not assign any fields
May 29, 2017
valhristov
changed the title
Fix S3963: False positive when static constructor does not assign any fields
Update S3963: Should not raise issue when the static constructor does not assign any fields
May 29, 2017
Evangelink
changed the title
Update S3963: Should not raise issue when the static constructor does not assign any fields
Fix S3963: Should not raise issue when the static constructor does not assign any fields
Jun 13, 2017
Description
Rule S3963, as far as I understand by reading the code, raises an error as soon as there is a static constructor. That picks up much more cases than the "Initialize all 'static fields' inline and remove the 'static constructor'" description would suggest.
Repro steps
Real life examples instead of a
WriteLine
: initialization of GUI component, static initialisation of a vendor's license, basically all sorts ofvoid
method calls with side effects.Expected behavior
No issue found
Actual behavior
S3963 is raised
Known workarounds
Turning off the rule or flagging as false positive
Related information
SonarQube 6.3.1
SonarCSharp 5.10.1 (build 1411)
MSBuild 14
The text was updated successfully, but these errors were encountered: