Example #1
0
        public void Close_OneParameterDisposedTwice(IInterface1 instance1, IInterface1 instance2)
        {
            instance1.Dispose();
            instance1.Dispose(); // Noncompliant
            instance1.Dispose(); // Noncompliant

            instance2.Dispose(); // ok - only disposed once
        }
 public static void LoopWithBreak(System.Collections.Generic.IEnumerable <string> list, bool condition, IInterface1 instance1)
 {
     foreach (string x in list)
     {
         try
         {
             if (condition)
             {
                 instance1.Dispose(); // Noncompliant
             }
             break;
         }
         catch (Exception)
         {
             continue;
         }
     }
 }
Example #3
0
 public void Close_ParametersOfSameTypes(IInterface1 instance1, IInterface1 instance2)
 {
     // Regression test for https://github.com/SonarSource/sonar-csharp/issues/1038
     instance1.Dispose();
     instance2.Dispose();
 }
Example #4
0
 public void Close_ParametersOfDifferenceTypes(IInterface1 interface1, IDisposable interface2)
 {
     // Regression test for https://github.com/SonarSource/sonar-csharp/issues/1038
     interface1.Dispose(); // ok, only called once on each parameter
     interface2.Dispose();
 }