Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix IDE0026 (use expression-bodied members for indexers)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
stephentoub committed Sep 6, 2019
1 parent 3585fbf commit bca5498
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public ReadOnlyCollection(IList<T> list)

public int Count => list.Count;

public T this[int index]
{
get { return list[index]; }
}
public T this[int index] => list[index];

public bool Contains(T value)
{
Expand Down
8 changes: 1 addition & 7 deletions src/Common/src/CoreLib/System/Globalization/DateTimeParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5896,13 +5896,7 @@ internal ref struct DTSubString
internal DTSubStringType type;
internal int value;

internal char this[int relativeIndex]
{
get
{
return s[index + relativeIndex];
}
}
internal char this[int relativeIndex] => s[index + relativeIndex];
}

//
Expand Down
5 changes: 1 addition & 4 deletions src/Common/src/CoreLib/System/ParamsArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ public ParamsArray(object?[] args)

public int Length => _args.Length;

public object? this[int index]
{
get { return index == 0 ? _arg0 : GetAtSlow(index); }
}
public object? this[int index] => index == 0 ? _arg0 : GetAtSlow(index);

private object? GetAtSlow(int index)
{
Expand Down
161 changes: 63 additions & 98 deletions src/Common/src/CoreLib/System/Tuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,13 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -409,19 +404,14 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -536,20 +526,15 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -673,21 +658,16 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -820,22 +800,17 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -977,23 +952,18 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
6 => Item7,
_ => throw new IndexOutOfRangeException(),
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
6 => Item7,
_ => throw new IndexOutOfRangeException(),
};
}

[Serializable]
Expand Down Expand Up @@ -1171,23 +1141,18 @@ string ITupleInternal.ToString(StringBuilder sb)
/// <summary>
/// Get the element at position <param name="index"/>.
/// </summary>
object? ITuple.this[int index]
{
get
object? ITuple.this[int index] =>
index switch
{
return index switch
{
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
6 => Item7,

_ => ((ITupleInternal)Rest)[index - 7],
};
}
}
0 => Item1,
1 => Item2,
2 => Item3,
3 => Item4,
4 => Item5,
5 => Item6,
6 => Item7,

_ => ((ITupleInternal)Rest)[index - 7],
};
}
}
Loading

0 comments on commit bca5498

Please sign in to comment.