Runtime: Consider removing Range.OffsetAndLength

Created on 22 Feb 2019  路  10Comments  路  Source: dotnet/runtime

We currently have this nested type for Range:

```C#
namespace System
{
public partial struct Range
{
public OffsetAndLength GetOffsetAndLength(int length);

    public readonly struct OffsetAndLength
    {
        public int Offset { get; }
        public int Length { get; }

        public OffsetAndLength(int offset, int length);
        public void Deconstruct(out int offset, out int length);
    }
}

}

However, considering that the outputs are fixed, we should consider making this simply a tuple:

```C#
namespace System
{
    public partial struct Range
    {
        public (int Offset, int Length) GetOffsetAndLength(int length);
    }
}

/cc @tarekgh @stephentoub @dotnet/fxdc

api-approved area-System.Runtime

Most helpful comment

We had a meeting on it today, and landed on PascalCasing. Since "OffsetAndLength" is pretty clearly just a 2-tuple, apparently Immo is excited to (re-)start our use of "AVOID" tuples instead of "DO NOT" use tuples.

All 10 comments

I agree this is simpler. I got push back during the code review against using Tuple as I had the original implementation in the PR as described here. anyway, I am fully agree with what proposed here.

I thought there was a general discussion about using Tuple in public API, @terrajobst and the feeling was that it wasn't a good idea - I recall mention was made of naming and tooling support. Do I remember wrong?

We had a meeting on it today, and landed on PascalCasing. Since "OffsetAndLength" is pretty clearly just a 2-tuple, apparently Immo is excited to (re-)start our use of "AVOID" tuples instead of "DO NOT" use tuples.

I feel called out 馃馃槑

@terrajobst I assume this is not approved yet. right? or should I assume otherwise.

I assume this is not approved yet. right?

Right. Still api-ready-for-review.

Yep, the intention of this item is to have the conversation with @dotnet/fxdc in the usual forum :-)

@tarekgh would you mind taking care of this as well?

@terrajobst sure :-) I am happy we are changing this.

This is done now.

Was this page helpful?
0 / 5 - 0 ratings