My nightly build failed last night. The issue was a code change that implemented a ReadOnly Property
as a full read/write Property
which it says isn't allowed.
That's fine (I can see arguments both ways, but it's clear enough). However, the same code compiles perfectly OK in Visual Studio (2015). But my scripted build calling msbuild from the command line fails.
A simple example to show the problem, the following code compiles OK in VS (and then runs fine too):
Module Module1
Interface IFoo
ReadOnly Property Bar As String
End Interface
Class Foo
Implements IFoo
Private _Bar As String
Public Property Bar As String Implements IFoo.Bar
Get
Return _Bar
End Get
Set(value As String)
_Bar = value
End Set
End Property
End Class
Sub Main()
Dim F As New Foo
F.Bar = "baz"
Console.WriteLine(F.Bar)
End Sub
End Module
But running the following command
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Foo.vbproj
fails with
Build FAILED.
"C:\Users\...\Foo\Foo\Foo.vbproj" (default target) (1) ->
(CoreCompile target) ->
C:\Users\...\Foo\Foo\Module1.vb(10,20): error BC30154: Class 'Foo' must
implement 'ReadOnly Property Bar As String' for interface 'IFoo'.
Implementing property must have matching 'ReadOnly'
or 'WriteOnly' specifiers. [C:\Users\..\Foo\Foo.vbproj]
C:\Users\...\Foo\Foo\Module1.vb(13,50): error BC30401: 'Bar' cannot
implement 'Bar' because there is no matching property on interface
'IFoo'. [C:\Users\...\Foo\Foo.vbproj]
0 Warning(s)
2 Error(s)
Changing the ReadOnly Property Bar As String
to just Property Bar As String
means it builds fine with the same command.
Questions:
Has something changed that this is allowed now and not earlier? Should I be using a newer msbuild? (Don't seem to have one installed currently)
Is there any way to get Visual Studio to behave the same as msbuild? I want to know that when I build in VS, it means it will build with msbuild too. I'm quite happy to accept this as an error, but I want VS to show it as an error.