Version Used:
Microsoft Visual Studio Professional 2017 Preview (2)
Version 15.8.0 Preview 1.1
VisualStudio.15.Preview/15.8.0-pre.1.1+27705.2000
Microsoft .NET Framework
Version 4.7.03056
Steps to Reproduce:
Compile the following code:
public class C
{
public void M((C, C) t)
{
bool b1 = t == t;
bool b2 = t != t;
}
[System.Obsolete("", error: true)]
public static extern implicit operator bool(C c);
public static extern C operator ==(C c1, C c2);
public static extern C operator !=(C c1, C c2);
}
Expected Behavior:
error CS0619: 'C.implicit operator bool(C)' is obsolete: ''
Actual Behavior:
Code compiles without errors.
Notes
- The compiler does emit calls to the obsolete operator:
IL_0016: call bool C::op_Implicit(class C)
- The compiler produces warnings/errors for obsolete implicit conversions in other scenarios, e.g. the line
bool b3 = t.Item1 == t.Item2;
won't be compiled in the example above as well as manually lowered version of the tuple comparison
bool flag = (bool)(t.Item1 == t.Item1) && (bool)(t.Item2 == t.Item2);
- The compiler produces warnings/errors for other obsolete operators used in tuple equality e.g. components'
== and != operators as well as true/false operators, i.e. the following code won't be compiled:
public class C
{
public void M((C, C) t)
{
bool b1 = t == t;
bool b2 = t == t;
}
[System.Obsolete("", error: true)] public static extern C operator ==(C c1, C c2);
[System.Obsolete("", error: true)] public static extern C operator !=(C c1, C c2);
[System.Obsolete("", error: true)] public static extern bool operator true(C c);
[System.Obsolete("", error: true)] public static extern bool operator false(C c);
}
with these errors:
error CS0619: 'C.operator false(C)' is obsolete: ''
error CS0619: 'C.operator ==(C, C)' is obsolete: ''
error CS0619: 'C.operator false(C)' is obsolete: ''
error CS0619: 'C.operator ==(C, C)' is obsolete: ''
error CS0619: 'C.operator false(C)' is obsolete: ''
error CS0619: 'C.operator ==(C, C)' is obsolete: ''
error CS0619: 'C.operator false(C)' is obsolete: ''`
/cc @jcouv
Version Used:
Microsoft Visual Studio Professional 2017 Preview (2)
Version 15.8.0 Preview 1.1
VisualStudio.15.Preview/15.8.0-pre.1.1+27705.2000
Microsoft .NET Framework
Version 4.7.03056
Steps to Reproduce:
Compile the following code:
Expected Behavior:
error CS0619: 'C.implicit operator bool(C)' is obsolete: ''Actual Behavior:
Code compiles without errors.
Notes
IL_0016: call bool C::op_Implicit(class C)bool b3 = t.Item1 == t.Item2;won't be compiled in the example above as well as manually lowered version of the tuple comparison
bool flag = (bool)(t.Item1 == t.Item1) && (bool)(t.Item2 == t.Item2);==and!=operators as well astrue/falseoperators, i.e. the following code won't be compiled:with these errors:
/cc @jcouv