Skip to content

Wrong ref expression : CS8374 #3438

@CreateAndInject

Description

@CreateAndInject

Original:

using System;
using System.Collections.Generic;

namespace Lsj.Util.Collections
{
    public static class ArrayHelper
    {
        public static (T value, int row, int col)[] ToThreeValueTuples<T>(this T[][] array)
        {
            var result = new List<ValueTuple<T, int, int>>();
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = 0; j < array[i].Length; j++)
                {
                    if (!array[i][j].Equals(default(T)))
                        result.Add((array[i][j], i, j));
                }
            }
            return result.ToArray();
        }
    }
}

ILSpy:

	public static (T value, int row, int col)[] ToThreeValueTuples<T>(this T[][] array)
	{
		List<(T, int, int)> result = new List<(T, int, int)>();
		for (int i = 0; i < array.Length; i++)
		{
			for (int j = 0; j < array[i].Length; j++)
			{
				ref readonly T reference = ref array[i][j];
				T val = default(T);
				if (val == null)
				{
					val = reference;
					reference = ref val;
				}
				if (!reference.Equals(default(T)))
				{
					result.Add((array[i][j], i, j));
				}
			}
		}
		return result.ToArray();
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDecompilerThe decompiler engine itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions