Skip to content

Navigate to decompiled sources: 'Unknown result type' in output #24178

@sharwell

Description

@sharwell

Version Used: 15.6 Preview 2

Steps to Reproduce:

  1. Add a reference to System.Collections.Immutable

  2. Add the following code:

    var array = ImmutableArray.CreateRange(Enumerable.Range(0, 1), x => x);
  3. Navigate to ImmutableArray.CreateRange

Expected Behavior:

  1. The signature of CreateRange is the following:

    public static ImmutableArray<TResult> CreateRange<TSource, TResult>(ImmutableArray<TSource> items, Func<TSource, TResult> selector)
  2. The decompiled method body does not have comments regarding invalid IL

  3. The use of selector is proper C# code

Actual Behavior:

  1. The signature of CreateRange is incorrect. Specifically, the generic arguments for the type of selector are omitted:

    public static ImmutableArray<TResult> CreateRange<TSource, TResult>(ImmutableArray<TSource> items, Func selector)
  2. The decompiled method body has comments regarding invalid IL:

    //IL_0000: Unknown result type (might be due to invalid IL)
    //IL_0029: Unknown result type (might be due to invalid IL)
    //IL_0032: Expected Ref, but got Unknown
  3. When selector is used to assign values to array[i], the types and syntax are incorrect (both (?) and (!0) are incorrect):

    array[i] = (TResult)((Func)(?)selector).Invoke((!0)items[i]);

📝 For reference, here is the complete decompiled method:

public static ImmutableArray<TResult> CreateRange<TSource, TResult>(ImmutableArray<TSource> items, Func selector)
{
	//IL_0000: Unknown result type (might be due to invalid IL)
	//IL_0029: Unknown result type (might be due to invalid IL)
	//IL_0032: Expected Ref, but got Unknown
	Requires.NotNull<Func>(selector, "selector");
	int length = items.Length;
	if (length == 0)
	{
		return ImmutableArray.Create<TResult>();
	}
	TResult[] array = new TResult[length];
	for (int i = 0; i < array.Length; i++)
	{
		array[i] = (TResult)((Func)(?)selector).Invoke((!0)items[i]);
	}
	return new ImmutableArray<TResult>(array);
}

Metadata

Metadata

Assignees

Labels

Area-IDEBugResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions