This is a migrated thread and some comments may be shown as answers.

Incorrect analysis of ref parameters

2 Answers 32 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David Larkin
Top achievements
Rank 1
David Larkin asked on 20 Aug 2010, 04:04 PM
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 Answers, 1 is accepted

Sort by
0
David Larkin
Top achievements
Rank 1
answered on 20 Aug 2010, 04:23 PM
Here is a screenshot of the problem.
0
Svetlozar
Telerik team
answered on 25 Aug 2010, 08:30 AM
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
Tags
General Discussions
Asked by
David Larkin
Top achievements
Rank 1
Answers by
David Larkin
Top achievements
Rank 1
Svetlozar
Telerik team
Share this question
or