Skip to content

Commit 48aa004

Browse files
committed
VB.NET template updated.
1 parent 163700d commit 48aa004

10 files changed

+71
-82
lines changed

doc/ChangeLog

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2013-02-21 Giacomo Stelluti Scala <[email protected]>
2+
3+
* HelpText, internal refactoring to safely suppress a CodeAnalysis warning.
4+
* Namespace Core renamed Infrastructure.
5+
* Extensions methods refacored in one class per group.
6+
* Fixed issue #6.
7+
* Using VSSTUDIO CodeAnalysis instead of FxCop.
8+
* CSharp and VB.NET template updated.
9+
110
2013-02-19 Giacomo Stelluti Scala <[email protected]>
211

312
* Trying to tatally complying to naming rules (see doc/Contributors).
@@ -26,11 +35,6 @@
2635
use HelpText::AutoBuild(object,string)
2736
* HelpText class:
2837
- added HelpText::AutoBuild(object,string)
29-
- internal refactoring to safely suppress a CodeAnalysis warning.
30-
* Namespace Core renamed Infrastructure.
31-
* Extensions methods refacored in one class per group.
32-
* Fixed issue #6.
33-
* Using VSSTUDIO CodeAnalysis instead of FxCop.
3438

3539
2013-02-18 Giacomo Stelluti Scala <[email protected]>
3640

src/templates/VBNetTemplate/My Project/Application.Designer.vb

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/templates/VBNetTemplate/My Project/Resources.Designer.vb

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/templates/VBNetTemplate/My Project/Settings.Designer.vb

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Region "License"
2+
'<copyright file="Options.vb" company="Your name here">
3+
' Copyright 2013 Your name here
4+
' </copyright>
5+
'
6+
' [License Body Here]
7+
#End Region
8+
#Region "Using Directives"
9+
Imports CommandLine
10+
Imports CommandLine.Text
11+
#End Region
12+
13+
Friend Class Options
14+
15+
<[Option]("t"c, "text", Required:=True, HelpText:="text value here")>
16+
Public Property TextValue As String
17+
18+
<[Option]("n"c, "numeric", HelpText:="numeric value here")>
19+
Public Property NumericValue As Double = 0
20+
21+
<[Option]("b"c, "bool", HelpText:="on|off switch here")>
22+
Public Property BooleanValue As Boolean
23+
24+
<HelpOption()>
25+
Public Function GetUsage() As String
26+
27+
Return HelpText.AutoBuild(Me, Sub(current As HelpText) HelpText.DefaultParsingErrorsHandler(Me, current))
28+
29+
End Function
30+
End Class
+14-50
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,28 @@
11
#Region "License"
2-
''
3-
'' Your Project Name Here: Program.vb
4-
''
5-
'' Author:
6-
'' Your Name Here ([email protected])
7-
''
8-
'' Copyright (C) 2012 Your Name Here
9-
''
10-
'' [License Body Here]
2+
'<copyright file="Options.vb" company="Your name here">
3+
' Copyright 2013 Your name here
4+
' </copyright>
5+
'
6+
' [License Body Here]
117
#End Region
128
#Region "Using Directives"
139
Imports CommandLine
1410
Imports CommandLine.Text
1511
#End Region
1612

1713
Friend NotInheritable Class Program
18-
Private Class Options
19-
Inherits CommandLineOptionsBase
2014

21-
<[Option]("t", "text", Required:=True, HelpText:="text value here")>
22-
Public Property TextValue As String
23-
24-
<[Option]("n", "numeric", HelpText:="numeric value here")>
25-
Public Property NumericValue As Double = 0
26-
27-
<[Option]("b", "bool", HelpText:="on|off switch here")>
28-
Public Property BooleanValue As Boolean
15+
Shared Sub Main(args As String())
2916

30-
<HelpOption()>
31-
Public Function GetUsage() As String
32-
Dim help = New HelpText() With {
33-
.Heading = New HeadingInfo(ThisAssembly.Title, ThisAssembly.InformationalVersion),
34-
.Copyright = New CopyrightInfo(ThisAssembly.Author, 2012),
35-
.AdditionalNewLineAfterOption = True,
36-
.AddDashesToOption = True}
37-
Me.HandleParsingErrorInHelp(help)
38-
help.AddPreOptionsLine("<<license details here.>>")
39-
help.AddPreOptionsLine("Usage: VBNetTemplate -tSomeText --numeric 2012 -b")
40-
help.AddOptions(Me)
17+
Dim options = New Options()
4118

42-
Return help
43-
End Function
19+
If Not CommandLine.Parser.Default.ParseArguments(args, options) Then
20+
Environment.Exit(CommandLine.Parser.DefaultExitCodeFail)
21+
End If
4422

45-
Private Sub HandleParsingErrorInHelp(help As HelpText)
46-
If Me.LastPostParsingState.Errors.Count > 0 Then
47-
Dim errors = help.RenderParsingErrorsText(Me, 2) ''indent by two spaces
48-
If Not String.IsNullOrEmpty(errors) Then
49-
help.AddPreOptionsLine(String.Concat(Environment.NewLine, "ERROR(S):"))
50-
help.AddPreOptionsLine(errors)
51-
End If
52-
End If
53-
End Sub
54-
End Class
23+
Console.WriteLine("t|ext: " + options.TextValue)
24+
Console.WriteLine("n|umeric: " & options.NumericValue)
25+
Console.WriteLine("b|ool: " & options.BooleanValue.ToString.ToLower)
5526

56-
Shared Sub Main(args As String())
57-
Dim options = New Options()
58-
If CommandLineParser.Default.ParseArguments(args, options) Then
59-
Console.WriteLine("t|ext: " + options.TextValue)
60-
Console.WriteLine("n|umeric: " & options.NumericValue)
61-
Console.WriteLine("b|ool: " & options.BooleanValue.ToString.ToLower)
62-
End If
6327
End Sub
64-
End Class
28+
End Class

src/templates/VBNetTemplate/ThisAssembly.vb

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#Region "License"
2-
''
3-
'' Your Project Name Here: ThisAssembly.vb
4-
''
5-
'' Author:
6-
'' Your Name Here ([email protected])
7-
''
8-
'' Copyright (C) 2012 Your Name Here
9-
''
10-
'' [License Body Here]
2+
'<copyright file="ThisAssembly.vb" company="Your name here">
3+
' Copyright 2013 Your name here
4+
' </copyright>
5+
'
6+
' [License Body Here]
117
#End Region
128

139
Friend Class ThisAssembly

src/templates/VBNetTemplate/VBNetTemplate.vbproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<AssemblyName>VBNetTemplate</AssemblyName>
1515
<FileAlignment>512</FileAlignment>
1616
<MyType>Console</MyType>
17-
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
17+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1818
<TargetFrameworkProfile>
1919
</TargetFrameworkProfile>
2020
<IsWebBootstrapper>false</IsWebBootstrapper>
@@ -91,6 +91,7 @@
9191
<Import Include="System.Xml.Linq" />
9292
</ItemGroup>
9393
<ItemGroup>
94+
<Compile Include="Options.vb" />
9495
<Compile Include="Program.vb" />
9596
<Compile Include="My Project\AssemblyInfo.vb" />
9697
<Compile Include="My Project\Application.Designer.vb">
@@ -118,6 +119,7 @@
118119
</EmbeddedResource>
119120
</ItemGroup>
120121
<ItemGroup>
122+
<None Include="app.config" />
121123
<None Include="My Project\app.manifest" />
122124
<None Include="My Project\Application.myapp">
123125
<Generator>MyApplicationCodeGenerator</Generator>

src/templates/VBNetTemplate/VBNetTemplate.vbproj.user

-13
This file was deleted.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)