1
1
Imports System.Reflection
2
2
Imports System.Text
3
- Imports Nukepayload2.Ra2CodeAnalysis.Linq
3
+ Imports Nukepayload2.CodeAnalysis
4
+ Imports Nukepayload2.CodeAnalysis.Linq
4
5
5
- Public Class VBProjectWriter
6
-
7
- ''' <summary>
8
- ''' 项目名称(不含拓展名)
9
- ''' </summary>
10
- Public Property ProjectName As String
11
- ''' <summary>
12
- ''' 生成与 .NET Standard 1.2 等价目标的 VB 14 类库项目文件
13
- ''' </summary>
14
- ''' <param name="CodeFileNames">生成的代码文件名(可以省略.vb拓展名)</param>
15
- Public Function GeneratePcl44Proj(CodeFileNames As IEnumerable( Of String )) As GeneratedCodeFile
16
- Dim xdoc =
17
- $"<?xml version=""1.0"" encoding=""utf-8" "?>
18
- <Project ToolsVersion= ""14.0"" DefaultTargets= "" Build "" xmlns= "" http://schemas.microsoft.com/developer/msbuild/ 2003"" >
19
- <Import Project= "" $(MSBuildExtensionsPath)\ $(MSBuildToolsVersion)\Microsoft.Common.props "" Condition= "" Exists( '$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')""/>
20
- <PropertyGroup>
21
- <MinimumVisualStudioVersion> 10.0 </MinimumVisualStudioVersion>
22
- <Configuration Condition= "" '$(Configuration)' == '' "">Debug</Configuration>
23
- <Platform Condition= "" '$(Platform)' == '' "">AnyCPU</Platform>
24
- <ProjectGuid>{{ 1F CBC551-B7E3- 4 FC8- 8 CCF- 111 A7A1F1469}}</ProjectGuid>
25
- <OutputType>Library</OutputType>
26
- <RootNamespace>{ProjectName}</RootNamespace>
27
- <AssemblyName>{ProjectName}</AssemblyName>
28
- <DefaultLanguage>zh-CN</DefaultLanguage>
29
- <ProjectTypeGuids>{{ 14182 A97-F7F0- 4 C62- 8 B27- 98 AA8AE2109A}} ;{{F184B08F-C81C- 45 F6-A57F- 5 ABD9991F28F}}</ProjectTypeGuids>
30
- <TargetFrameworkProfile>Profile44</TargetFrameworkProfile>
31
- <TargetFrameworkVersion>v4 .6 </TargetFrameworkVersion>
32
- </PropertyGroup>
33
- <PropertyGroup Condition= "" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
34
- <DebugSymbols> true </DebugSymbols>
35
- <DebugType>full</DebugType>
36
- <DefineDebug> true </DefineDebug>
37
- <DefineTrace> true </DefineTrace>
38
- <DefineConstants>
39
- </DefineConstants>
40
- <OutputPath>bin\Debug</OutputPath>
41
- <DocumentationFile>{ProjectName}.xml</DocumentationFile>
42
- <NoWarn> 40057 , 42016 , 41999 , 42020 , 42021 , 42022 </NoWarn>
43
- <WarningsAsErrors> 42017 , 42018 , 42019 , 42032 , 42036 </WarningsAsErrors>
44
- </PropertyGroup>
45
- <PropertyGroup Condition= "" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "">
46
- <DebugType>pdbonly</DebugType>
47
- <DefineDebug> false </DefineDebug>
48
- <DefineTrace> true </DefineTrace>
49
- <DefineConstants>
50
- </DefineConstants>
51
- <Optimize> true </Optimize>
52
- <OutputPath>bin\Release</OutputPath>
53
- <DocumentationFile>{ProjectName}.xml</DocumentationFile>
54
- <NoWarn> 40057 , 42016 , 41999 , 42020 , 42021 , 42022 </NoWarn>
55
- <WarningsAsErrors> 42017 , 42018 , 42019 , 42032 , 42036 </WarningsAsErrors>
56
- </PropertyGroup>
57
- <PropertyGroup>
58
- <OptionExplicit> On </OptionExplicit>
59
- </PropertyGroup>
60
- <PropertyGroup>
61
- <OptionCompare>Binary</OptionCompare>
62
- </PropertyGroup>
63
- <PropertyGroup>
64
- <OptionStrict> On </OptionStrict>
65
- </PropertyGroup>
66
- <PropertyGroup>
67
- <OptionInfer> On </OptionInfer>
68
- </PropertyGroup>
69
- <ItemGroup>
70
- <Import Include= "" Microsoft.VisualBasic "" />
71
- <Import Include= "" System "" />
72
- <Import Include= "" System.Collections "" />
73
- <Import Include= "" System.Collections.Generic "" />
74
- <Import Include= "" System.Collections.ObjectModel "" />
75
- <Import Include= "" System.ComponentModel "" />
76
- <Import Include= "" System.Diagnostics "" />
77
- <Import Include= "" System.IO "" />
78
- <Import Include= "" System.Linq "" />
79
- <Import Include= "" System.Runtime.CompilerServices "" />
80
- <Import Include= "" System.Threading.Tasks "" />
81
- <Import Include= "" System.Xml.Linq "" />
82
- <Import Include= "" System.ComponentModel.DataAnnotations "" />
83
- </ItemGroup>
84
- <ItemGroup>
85
- { Aggregate f In CodeFileNames Select $"<Compile Include=""{If(f.EndsWith(" .vb "), f, f + " .vb ")}""/>" Into Join ( 8 )}
86
- <Compile Include= "" My Project\AssemblyInfo.vb "" />
87
- </ItemGroup>
88
- <ItemGroup>
89
- <None Include= "" packages.config "" />
90
- </ItemGroup>
91
- <Import Project= "" $(MSBuildExtensionsPath32)\Microsoft\Portable\ $(TargetFrameworkVersion)\Microsoft.Portable.VisualBasic.targets "" />
92
- </Project> "
93
- Return New GeneratedCodeFile(ProjectName + ".vbproj" , xdoc)
94
- End Function
95
-
96
- Public Function GenerateAssemblyInfo() As GeneratedCodeFile
97
- Dim fileName = "AssemblyInfo.vb"
98
- Dim content = $"Imports System
99
- Imports System.Resources
100
- Imports System.Reflection
101
-
102
- ' 有关程序集的一般信息由以下
103
- ' 控制。更改这些特性值可修改
104
- ' 与程序集关联的信息。
105
-
106
- '查看程序集特性的值
107
-
108
- < Assembly : AssemblyTitle( "" {ProjectName} "" )>
109
- < Assembly : AssemblyDescription( "" 由 Nukepayload2.Ra2CodeAnalysis 生成 "" )>
110
- < Assembly : AssemblyCompany( """" )>
111
- < Assembly : AssemblyProduct( "" {ProjectName} "" )>
112
- < Assembly : AssemblyCopyright( "" 版权所有(C) 2016"" )>
113
- < Assembly : AssemblyTrademark( """" )>
114
- < Assembly : NeutralResourcesLanguage( "" zh-Hans "" )>
115
-
116
- ' 程序集的版本信息由下列四个值组成:
117
- '
118
- ' 主版本
119
- ' 次版本
120
- ' 生成号
121
- ' 修订号
122
- '
123
- '可以指定所有这些值,也可以使用 ""生成号"" 和 ""修订号"" 的默认值,
124
- ' 方法是按如下所示使用""*"": :
125
- ' <Assembly: AssemblyVersion(""1.0.*"")>
126
-
127
- < Assembly : AssemblyVersion( ""1.0.0.0"" )>
128
- < Assembly : AssemblyFileVersion( ""1.0.0.0"" )>
129
- "
130
- Return New GeneratedCodeFile(fileName, content)
131
- End Function
132
-
133
- ''' <summary>
134
- ''' 获取嵌入的类型以便解析某些ini文件
135
- ''' </summary>
136
- Public Async Function GetEmbeddedCodeFileAsync() As Task( Of GeneratedCodeFile)
137
- Dim content As String
138
- Using strm = Me .GetType.GetTypeInfo.Assembly.GetManifestResourceStream( "Nukepayload2.Ra2CodeAnalysis.Percentage.vb" ), sr = New StreamReader(strm, Encoding.UTF8)
139
- content = Await sr.ReadToEndAsync()
140
- End Using
141
- Return New GeneratedCodeFile( "Percentage.vb" , content)
142
- End Function
143
-
144
- Public Function GeneratePackageConfig() As GeneratedCodeFile
145
- Return New GeneratedCodeFile( "packages.config" , "<?xml version=""1.0"" encoding=""utf-8" "?>
146
- <packages>
147
- <package id= "" System.ComponentModel.Annotations "" version= ""4.1.0"" targetFramework= "" portable46-net451+win81 "" />
148
- </packages> ")
149
- End Function
6
+ Public Module VBProjectWriterExtension
150
7
8
+ <Extension>
151
9
Public Function GenerateVBFileFromIni(d As NamedIniAnalyzer) As GeneratedCodeFile
152
10
Dim hlp As HelpProvider = New EmptyHelpProvider
153
11
Select Case d.FileNameWithoutExt.ToLower
@@ -173,4 +31,4 @@ Imports System.Reflection
173
31
ns.EndBlock()
174
32
Return New GeneratedCodeFile(d.FileNameWithoutExt + ".vb" , sb.ToString)
175
33
End Function
176
- End Class
34
+ End Module
0 commit comments