VB.NET code with indexer properies with optional parameter:
<System.Runtime.InteropServices.ComImport>
Public Class VBClass
Public ReadOnly Property Prop(Optional ByVal i As Integer = 0) As VBClassWithIndexer
Get
Return New VBClassWithIndexer()
End Get
End Property
End Class
Public Class VBClassWithIndexer
Public ReadOnly Default Property Prop(ByVal s As String) As Integer
Get
Return 0
End Get
End Property
End Class
C# 5.0 compiler allows using parentheses to reference indexer property without supplying arguments:
class C {
public void Foo(VBClass c) {
int i1 = c.Prop[""]; // wrong argument type, int expected
int i2 = (c.Prop)[""]; // OK, [""] is invoked over 'VBClassWithIndexer' type
}
}
While C# 6.0 compiler always ignores parentheses:
class C {
public void Foo(VBClass c) {
int i1 = c.Prop[""]; // wrong argument type, int expected
int i2 = (c.Prop)[""]; // wrong argument type, int expected
}
}
I couldn't find anything like this in the list of documented breaking changes in Roslyn (#7278).
Is this a breaking change or a bug?
VB.NET code with indexer properies with optional parameter:
C# 5.0 compiler allows using parentheses to reference indexer property without supplying arguments:
While C# 6.0 compiler always ignores parentheses:
I couldn't find anything like this in the list of documented breaking changes in Roslyn (#7278).
Is this a breaking change or a bug?