Examples of errors detected by the V3061 diagnostic

V3061. Parameter 'A' is always rewritten in method body before being used.


Xenko

V3061 Parameter 'internalEvent' is always rewritten in method body before being used. SiliconStudio.Xenko ParameterCollection.cs 1158


internal delegate void InternalValueChangedDelegate(
  InternalValue internalValue, object oldValue);

private static InternalValueChangedDelegate
CreateInternalValueChangedEvent(
  ParameterKey key,
  InternalValueChangedDelegate internalEvent,
  ValueChangedDelegate originalEvent)
{
    internalEvent = (internalValue, oldValue) =>
      originalEvent(key, internalValue, oldValue);
    return internalEvent;
}

Xenko

V3061 Parameter 'libraryData' is always rewritten in method body before being used. SiliconStudio.TextureConverter DxtTexLib.cs 213


private void Load(TexImage image,
                         DxtTextureLibraryData libraryData,
                         LoadingRequest loader)
{
  ....
  libraryData = new DxtTextureLibraryData(); // <=
  image.LibraryData[this] = libraryData;

  libraryData.Image = new ScratchImage();
  ....
}

Similar errors can be found in some other places:

  • V3061 Parameter 'libraryData' is always rewritten in method body before being used. SiliconStudio.TextureConverter FITexLib.cs 244

Accord.Net

V3061 Parameter 'mode' is always rewritten in method body before being used. Accord.Statistics TriangularDistribution.cs 646


private static double WeightedMode(double[] observations,
                                   double[] weights,
                                   double mode,
                                   int imax,
                                   int imin)
{
  ....
  var bestValue = currentValue;
  ....
  mode = bestValue;
  return mode;
}

Similar errors can be found in some other places:

  • V3061 Parameter 'mode' is always rewritten in method body before being used. Accord.Statistics TriangularDistribution.cs 678
  • V3061 Parameter 'mode' is always rewritten in method body before being used. Accord.Statistics TriangularDistribution.cs 706
  • V3061 Parameter 'mode' is always rewritten in method body before being used. Accord.Statistics TriangularDistribution.cs 735

Old NASA World Wind (C#)

V3061 Parameter 'fDistance' is always rewritten in method body before being used. GPSTrackerPlugin.WorldWind.cs 1667


void ShowInfo(.... , float fDistance )
{
  ....
  if (m_fTotalDistance>=0F)
  {
    string sUnit=(m_fTotalDistance>=1F)?"km":"m";
    fDistance = (m_fTotalDistance < 1F) ?
                (m_fTotalDistance * 1000F) :
                 m_fTotalDistance;
    sInfo += "Track Distance: " +
              Convert.ToString(
               decimal.Round(
                Convert.ToDecimal(fDistance),3)) +
              sUnit +
              "\n";
  }
  ....
}

MSBuild

V3061 Parameter 'numericValue' is always rewritten in method body before being used. NodePacketTranslator.cs 320


public void TranslateEnum<T>(ref T value, int numericValue)
{
  numericValue = _reader.ReadInt32();  // <=
  Type enumType = value.GetType();
  value = (T)Enum.ToObject(enumType, numericValue);
}

Similar errors can be found in some other places:

  • V3061 Parameter 'defaultToolsVersion' is always rewritten in method body before being used. ToolsetProvider.cs 118

Mono

V3061 Parameter 'errorInfo' is always rewritten in method body before being used. corlib-net_4_x Marshal.cs 1552


internal static int SetErrorInfo (int dwReserved,
                                  IErrorInfo errorInfo)
{
  int retVal = 0;
  errorInfo = null;  // <=

  ....
  retVal = _SetErrorInfo (dwReserved, errorInfo);
  ....
}

.NET Core Libraries (CoreFX)

V3061 Parameter 'docPos' is always rewritten in method body before being used. CanonicalXmlDocument.cs 37


public void Write(StringBuilder strBuilder,
                  DocPosition docPos,
                  AncestralNamespaceContextManager anc)
{
  docPos = DocPosition.BeforeRootElement; // <=
  foreach (XmlNode childNode in ChildNodes)
  {
    if (childNode.NodeType == XmlNodeType.Element)
    {
      ....
      docPos = DocPosition.AfterRootElement;
    }
    else
    {
      CanonicalizationDispatcher.Write(
        childNode, strBuilder, docPos, anc); // <=
    }
  }
}

Similar errors can be found in some other places:

  • V3061 Parameter 'docPos' is always rewritten in method body before being used. CanonicalXmlDocument.cs 54

Telerik UI for UWP

V3061 Parameter 'index' is always rewritten in method body before being used. DataEngine.cs 1443


private static Tuple<Group, int> FindGroupAndItemIndex(.... int index, ....)
{
  if (exhaustiveSearch)
  {
    ....
  }
  else
  {
    var aggregateRowGroup = rowRootGroup;
    var rowGroupNames = valueProvider.GetRowGroupNames(item);
    foreach (var groupName in rowGroupNames)
    {
      Group group;
      if (aggregateRowGroup.TryGetGroup(groupName, out group))
      {
        aggregateRowGroup = group;
      }
    }

    index = aggregateRowGroup.IndexOf(item, valueProvider.GetSortComparer());

    return Tuple.Create(aggregateRowGroup, index);
  }
}

RavenDB

V3061 Parameter 'numberOfResults' is always rewritten in method body before being used. DocumentHandler.cs(273), DocumentHandler.cs(267) Raven.Server


private async Task<int> WriteDocumentsJsonAsync(...., int numberOfResults)
{
  using (
    var writer = new AsyncBlittableJsonTextWriter(
      context,
      ResponseBodyStream(),
      Database.DatabaseShutdown
    )
  )
  {
    writer.WriteStartObject();
    writer.WritePropertyName(nameof(GetDocumentsResult.Results));
    numberOfResults = await writer.WriteDocumentsAsync(            // <=
      context,
      documentsToWrite,
      metadataOnly
    );

    ....
  }
  return numberOfResults;
}


Bugs Found

Checked Projects
414
Collected Errors
14 218
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept