GetやSetは、毎回同じことを書くのが面倒なので、自動実装することができます。
11 Public Property Myname() As String 12 Get 13 Return _myname 14 End Get 15 Set(ByVal value As String) 16 _myname = value 17 End Set 18 End Property
このように一行に置き換えます。
11 Public Property Myname As String
では、自動実装に置き換えたソースをビルドして、
takk@deb9:~/vbtest$ vbnc test.vb Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball) Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved. /home/takk/vbtest/test.vb (11,5) : error VBNC90019: Expected 'End'. /home/takk/vbtest/test.vb (11,5): Compiler error around this location, the compiler hasn't implemented the error message, nor error recovery, so the compiler will probably crash soon. at vbnc.Helper.ErrorRecoveryNotImplemented (vbnc.Span Location) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseRegularPropertyMemberDeclaration (vbnc.TypeDeclaration Parent, vbnc.ParseAttributableInfo Info) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseTypeMembers (vbnc.TypeDeclaration Parent) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseClassDeclaration (vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseTypeDeclaration (vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseAssemblyMembers (vbnc.AssemblyDeclaration Parent, System.String RootNamespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseAssemblyDeclaration (System.String RootNamespace, vbnc.AssemblyDeclaration assembly) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.Parse (System.String RootNamespace, vbnc.AssemblyDeclaration assembly) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile_Parse () [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile () [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile (System.String[] CommandLine) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Main.Main (System.String[] CmdArgs) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 /home/takk/vbtest/test.vb (11,5) : error VBNC30205: End of statement expected. /home/takk/vbtest/test.vb (11,5): Compiler error around this location, the compiler hasn't implemented the error message, nor error recovery, so the compiler will probably crash soon. at vbnc.Helper.ErrorRecoveryNotImplemented (vbnc.Span Location) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseRegularPropertyMemberDeclaration (vbnc.TypeDeclaration Parent, vbnc.ParseAttributableInfo Info) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseTypeMembers (vbnc.TypeDeclaration Parent) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseClassDeclaration (vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseTypeDeclaration (vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseAssemblyMembers (vbnc.AssemblyDeclaration Parent, System.String RootNamespace) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.ParseAssemblyDeclaration (System.String RootNamespace, vbnc.AssemblyDeclaration assembly) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Parser.Parse (System.String RootNamespace, vbnc.AssemblyDeclaration assembly) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile_Parse () [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile () [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Compiler.Compile (System.String[] CommandLine) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 at vbnc.Main.Main (System.String[] CmdArgs) [0x00000] in <d77f4191aaaa4ed9a9a36d67dd32844d>:0 /home/takk/vbtest/test.vb (10,17) : error VBNC30124: Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'. There were 3 errors and 0 warnings. Compilation took 00:00:00.2412190 takk@deb9:~/vbtest$
なんだこれは!
意図しないエラーがたくさん。
もしや古いバージョンのmonoだと、自動実装使えないのでは?
ということで、最新を落としてきます。
https://www.mono-project.com/download/stable/#download-lin
公式ページにあるとおり、実行
sudo apt install apt-transport-https dirmngr sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update
インストール。
sudo apt install mono-devel
さらにVBも。
sudo apt install mono-vbnc
バージョンを確認。
takk@deb9:~/vbtest$ vbnc --version Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.7 - tarball) Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved. vbnc : Command line : warning VBNC2009: the option -version was not recognized - ignored vbnc : Command line : error VBNC2011: No files to compile! Cannot do anything! Compilation took 00:00:00.0910720 takk@deb9:~/vbtest$
Mono 4.0.1が4.7になってますが、VBのバージョンは、0.0.0.5943のまま。ってことは、ビルドしても、結果は同じ気がしますが、やってみます。
takk@deb9:~/vbtest$ vbnc test.vb Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.7 - tarball) Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved. ~省略~ /home/takk/vbtest/test.vb (10,17) : error VBNC30124: Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'. There were 3 errors and 0 warnings. Compilation took 00:00:00.2981070 takk@deb9:~/vbtest$
やはりだめですねえ。
コメント