Interface 'implements' bug in 1.1.4322

G

Gazarsgo

Came across this today using .NET Framework 1.1 Version 1.1.4322:

VB.Net code:

Public Interface IFace1
Property Foo
End Interface

Public Interface IFace2
Inherits IFace1

Property Bar Implements IFace1.AnyTextHere
End Interface

---end---

This compiles fine!

My best guess is that the behavior seen is that since the
implementation of an interface member is deferred to classes that
implement the interface, the only compiler-time resolution done is to
verify that IFace1 exists.

I had no luck searching on this topic; is it a known bug or fixed in
2.0?

--gazarsgo
 
C

Chris Dunaway

Gazarsgo said:
This compiles fine!

Not on my machine with Option Strict On. It compiles with Option
Strict Off, however.
My best guess is that the behavior seen is that since the
implementation of an interface member is deferred to classes that
implement the interface, the only compiler-time resolution done is to
verify that IFace1 exists.

Try turning Option Strict On and see what you get.
 
G

Gazarsgo

Sorry, I thought it was verboten that I had Option Strict On and Option
Explicit On. I thought this was the case too though when I first ran
into an example of this code, but I replaced the missing Option
statements and still got no compile errors. What compile error did you
get, and what version of the .NET Framework are you running?

Here is a more complete example (a Console Application):
---start code---
Option Strict On
Option Explicit On

Public Interface TestIFace1

End Interface
Public Interface TestIFace2
Inherits TestIFace1
Property testProperty() As String Implements TestIFace1.Anything

End Interface
Public Class TestClass1
Implements TestIFace2

Public Property testProperty() As String Implements
TestIFace2.testProperty
Get
Return "Get"
End Get
Set(ByVal Value As String)
System.Console.Out.WriteLine("Set: " & Value)
End Set
End Property

Public Shared Sub Main()
Dim o As TestIFace1
o = New TestClass1
System.Console.Out.WriteLine(CType(o,
TestIFace2).testProperty())

End Sub
End Class

--endcode---

Thanks,
--gazarsgo
 
C

Chris Dunaway

That code *does* compile and does not show any errors. But that is
slightly different than your previous code. Your previous code had a
property defined in the base interface. But it is really weird that
nothing is flagged.
 
J

Jay B. Harlow [MVP - Outlook]

Gazarsgo,
The same problem appears in .NET 2.0 also.

I consider it a bug as I would expect a compile error as Property Bar cannot
"implement" anything on IFace1, as IFace2 does not "implement" IFace1.
IFace2 *inherits* IFace1.


I will submit a query to MS to see what they have to say.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Came across this today using .NET Framework 1.1 Version 1.1.4322:
|
| VB.Net code:
|
| Public Interface IFace1
| Property Foo
| End Interface
|
| Public Interface IFace2
| Inherits IFace1
|
| Property Bar Implements IFace1.AnyTextHere
| End Interface
|
| ---end---
|
| This compiles fine!
|
| My best guess is that the behavior seen is that since the
| implementation of an interface member is deferred to classes that
| implement the interface, the only compiler-time resolution done is to
| verify that IFace1 exists.
|
| I had no luck searching on this topic; is it a known bug or fixed in
| 2.0?
|
| --gazarsgo
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top