Home All Groups Group Topic Archive Search About

VB.NET compiler does not find type error at compiletime

Author
5 May 2007 9:27 AM
PitG
Here the facts as code sample:

Public Class Class1
    Sub ABC(ByVal item As IUnit)
    End Sub
End Class

Public Interface IUnit ' or any other Interface
    ReadOnly Property Heureka() As Activator
    ReadOnly Property Reference() As String
    ReadOnly Property Name() As String
End Interface

This client is calling ABC the wrong way!
Public Class Class2
    Sub test()
        Dim C1 As New Class1
        C1.ABC("aberhallo")
    End Sub
End Class

the .NET 2.0 Compiler does not see this type error at compiletime but at
runtime!
We tried sharpening the compiler with all potential options, but no success.

(this kind of bug is produced many times by the VB6 to .NET migration tool -
which is a serious issue if you have about 700 classes to check ...)

Does someone know what went wrong here - or even better to get around this?

--
PG

Author
5 May 2007 3:15 PM
AMercer
..NET 2003, fw 1.1 (sp1, option strict on) catches this error.  I know it is a
step backwards, but maybe you could use .NET 2003 as a migration tool.

Show quoteHide quote
"PitG" wrote:

> Here the facts as code sample:
>
> Public Class Class1
>     Sub ABC(ByVal item As IUnit)
>     End Sub
> End Class
>
> Public Interface IUnit ' or any other Interface
>     ReadOnly Property Heureka() As Activator
>     ReadOnly Property Reference() As String
>     ReadOnly Property Name() As String
> End Interface
>
> This client is calling ABC the wrong way!
> Public Class Class2
>     Sub test()
>         Dim C1 As New Class1
>         C1.ABC("aberhallo")
>     End Sub
> End Class
>
> the .NET 2.0 Compiler does not see this type error at compiletime but at
> runtime!
> We tried sharpening the compiler with all potential options, but no success.
>
> (this kind of bug is produced many times by the VB6 to .NET migration tool -
> which is a serious issue if you have about 700 classes to check ...)
>
> Does someone know what went wrong here - or even better to get around this?
>
> --
> PG
Author
5 May 2007 4:59 PM
Tom Shelton
On May 5, 3:27 am, PitG <P***@discussions.microsoft.com> wrote:
Show quoteHide quote
> Here the facts as code sample:
>
> Public Class Class1
>     Sub ABC(ByVal item As IUnit)
>     End Sub
> End Class
>
> Public Interface IUnit ' or any other Interface
>     ReadOnly Property Heureka() As Activator
>     ReadOnly Property Reference() As String
>     ReadOnly Property Name() As String
> End Interface
>
> This client is calling ABC the wrong way!
> Public Class Class2
>     Sub test()
>         Dim C1 As New Class1
>         C1.ABC("aberhallo")
>     End Sub
> End Class
>
> the .NET 2.0 Compiler does not see this type error at compiletime but at
> runtime!
> We tried sharpening the compiler with all potential options, but no success.
>
> (this kind of bug is produced many times by the VB6 to .NET migration tool -
> which is a serious issue if you have about 700 classes to check ...)
>
> Does someone know what went wrong here - or even better to get around this?
>
> --
> PG

Do you have option strict turned on?  My guess is no.

--
Tom Shelton
Author
5 May 2007 6:07 PM
PitG
Hi Tom,

you are right - i did not set the Option Strict ON for this simple example
code.

BUT: the Project itselft was worked on with Option Strict ON set at project
level and there is no message! (i just rechecked)

The reason for not finding the bugs is a automatically (by the converter)
placed statement on each code file of:
Option Strict Off

which overrides the central settings of Option Strict ON.

So thanks - i could go and "hunting bugs"

--
PG


Show quoteHide quote
"Tom Shelton" wrote:

> On May 5, 3:27 am, PitG <P***@discussions.microsoft.com> wrote:
> > Here the facts as code sample:
> >
> > Public Class Class1
> >     Sub ABC(ByVal item As IUnit)
> >     End Sub
> > End Class
> >
> > Public Interface IUnit ' or any other Interface
> >     ReadOnly Property Heureka() As Activator
> >     ReadOnly Property Reference() As String
> >     ReadOnly Property Name() As String
> > End Interface
> >
> > This client is calling ABC the wrong way!
> > Public Class Class2
> >     Sub test()
> >         Dim C1 As New Class1
> >         C1.ABC("aberhallo")
> >     End Sub
> > End Class
> >
> > the .NET 2.0 Compiler does not see this type error at compiletime but at
> > runtime!
> > We tried sharpening the compiler with all potential options, but no success.
> >
> > (this kind of bug is produced many times by the VB6 to .NET migration tool -
> > which is a serious issue if you have about 700 classes to check ...)
> >
> > Does someone know what went wrong here - or even better to get around this?
> >
> > --
> > PG
>
> Do you have option strict turned on?  My guess is no.
>
> --
> Tom Shelton
>
>
Author
10 May 2007 3:51 AM
Michael D. Ober
This is just one more example of why you are actually better off using
copy/paste to convert VB 6 code.  More VB 6 code will actually convert
better without the project converter.

Mike.


Show quoteHide quote
"PitG" <P***@discussions.microsoft.com> wrote in message
news:0A42E64E-CF8D-4AAC-8AE0-D28FBB2AAC6E@microsoft.com...
> Hi Tom,
>
> you are right - i did not set the Option Strict ON for this simple example
> code.
>
> BUT: the Project itselft was worked on with Option Strict ON set at
> project
> level and there is no message! (i just rechecked)
>
> The reason for not finding the bugs is a automatically (by the converter)
> placed statement on each code file of:
> Option Strict Off
>
> which overrides the central settings of Option Strict ON.
>
> So thanks - i could go and "hunting bugs"
>
> --
> PG
>
>
> "Tom Shelton" wrote:
>
>> On May 5, 3:27 am, PitG <P***@discussions.microsoft.com> wrote:
>> > Here the facts as code sample:
>> >
>> > Public Class Class1
>> >     Sub ABC(ByVal item As IUnit)
>> >     End Sub
>> > End Class
>> >
>> > Public Interface IUnit ' or any other Interface
>> >     ReadOnly Property Heureka() As Activator
>> >     ReadOnly Property Reference() As String
>> >     ReadOnly Property Name() As String
>> > End Interface
>> >
>> > This client is calling ABC the wrong way!
>> > Public Class Class2
>> >     Sub test()
>> >         Dim C1 As New Class1
>> >         C1.ABC("aberhallo")
>> >     End Sub
>> > End Class
>> >
>> > the .NET 2.0 Compiler does not see this type error at compiletime but
>> > at
>> > runtime!
>> > We tried sharpening the compiler with all potential options, but no
>> > success.
>> >
>> > (this kind of bug is produced many times by the VB6 to .NET migration
>> > tool -
>> > which is a serious issue if you have about 700 classes to check ...)
>> >
>> > Does someone know what went wrong here - or even better to get around
>> > this?
>> >
>> > --
>> > PG
>>
>> Do you have option strict turned on?  My guess is no.
>>
>> --
>> Tom Shelton
>>
>>
>