Incorrect analysis of ref parameters

3 posts, 0 answers
  1. David Larkin
    David Larkin avatar
    2 posts
    Member since:
    Jun 2010

    Posted 20 Aug 2010 Link to this post

    Hi,

    In the following sample application should the ref bool parameter be identified as being unused? I don't think that it should but JustCode does report is as such.

    Thanks,

    David

    using System;
    using System.Text;
    using System.Data;
    using System.Diagnostics;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main()
            {
                bool bUpdatedLineItem = false;

                StringBuilder sb = new StringBuilder();
                DataTable dt = new DataTable();
                dt.Columns.Add("Price", typeof(double));

                for(int i = 0; i < 10; i++)
                {
                    dt.Rows.Add((i + 1) * 1.5);
                }

                DataRow[] rows = dt.Select();
                foreach(DataRow thisRow in rows)
                {
                    CompareDoubleValues(rows, thisRow, sb, "Price", ref bUpdatedLineItem);
                }

                Debug.Print("Line item updated = {0}", bUpdatedLineItem);
            }

            private static void CompareDoubleValues(DataRow[] drAry, DataRow dw, StringBuilder sb, string columnName, ref bool bUpdatedLineItem)
            {
                if(Convert.ToDouble(drAry[0][columnName]) != Convert.ToDouble(dw[columnName]))
                {
                    drAry[0][columnName] = dw[columnName];
                    bUpdatedLineItem = true;

                    if(sb != null)
                    {
                        sb.Append(columnName).Append(" = ").Append(dw[columnName].ToString()).Append(",");
                    }
                }
            }
        }
    }
  2. David Larkin
    David Larkin avatar
    2 posts
    Member since:
    Jun 2010

    Posted 20 Aug 2010 Link to this post

    Here is a screenshot of the problem.
  3. DevCraft banner
  4. Svetlozar
    Admin
    Svetlozar avatar
    271 posts

    Posted 25 Aug 2010 Link to this post

    Hello David Larkin,

    Thank you for your feedback. This is a known issue that is already logged in our system. It will be fixed for the Q3 release.

    If you have any other problems or suggestions please don't hesitate to write back.

    Regards,
    Svetlozar Angelov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top