-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Description
I'm using C# 7.2 and version 15.5.3 of VS 2017 Enterprise.
Unless I'm doing something wrong, it looks like deconstruction into valuetuples using extension methods along with the in keyword for readonly pass in by reference prevents the unpacking syntax. See below.
Steps to Reproduce:
The following compiles fine:
public static void Deconstruct(this ushort source, out byte first, out byte second)
{
first = (byte)(source >> 8);
second = (byte)(source & byte.MaxValue);
}
public static void TestDeconstruct()
{
ushort source = 0;
(var first, var second) = source;
}The following does not compile (using the in keyword for the source ushort):
public static void Deconstruct(in this ushort source, out byte first, out byte second)
{
first = (byte)(source >> 8);
second = (byte)(source & byte.MaxValue);
}
public static void TestDeconstruct()
{
ushort source = 0;
(var first, var second) = source;
}Expected Behavior:
Both should compile fine and the second example that currently does not compile should also pass in the source ushort by reference.
dzmitry-lahoda