Wrong static type in Dump?

I'm using LINQPad 7 (v7.8.10) side-by-side with 8 beta (v8.8.1) and I'm seeing a difference in the static type that LINQPad prints when calling Enumerable.Range as seen below. According to the docs the static type should be IEnumerable <int> for at least most recent versions of .NET, just as LINQPad 7 prints it.

Is there maybe a glitch with the 8 beta version?

Comments

  • i2van
    edited January 2025

    Looks like type is correct:

    Enumerable.Range(3, 5).GetType().Dump();
    

    Latest 8 beta:System.Linq.Enumerable+RangeIterator
    Latest 5: System.Linq.Enumerable+<RangeIterator>d__113

    Enumerable.Range(3, 5).ToList().GetType().Dump();
    

    Latest 8 beta: System.Collections.Generic.List``1[System.Int32]

  • sgmoore
    edited January 2025

    Looks to be a framework change/issue

    Frameworks 8 and 9 show IList and earlier versions show IEnumerable

    Linqpad 7 doesn't fully support Framework 8, but it also shows IList when using a early rc of 8.

  • Enumerable.Range(3, 5).GetType().Dump(); shows the same type System.Linq.Enumerable+RangeIterator in 8 latest beta regardless .NET

  • Run the following with the .NET dropdown set to .NET 7 and then .NET 8:

    Environment.Version.Dump();
    Enumerable.Range(3, 5).GetType().GetInterfaces().Dump();
    

    You'll see that IList has been added in .NET 8. Note that LINQPad shows the runtime type in the Dump header.

  • There are a lot of types listed. Why exactly IList is selected?

  • It's the most derived (apart from the concrete class, RangeIterator, which is skipped because it's non-public).

  • Why not IReadOnlyList? Cause IList is mutable?

  • If two types are similarly derived, it picks the first in the list. In this case, IList is preferable, so there wasn't a need to special-case this.