9
9
// modifications are permitted.
10
10
11
11
using Microsoft . CodeAnalysis ;
12
- using Microsoft . CodeAnalysis . CSharp ;
13
- using Microsoft . CodeAnalysis . Emit ;
14
12
using Neo . IO ;
15
13
using Neo . Json ;
16
14
using Neo . Optimizer ;
21
19
using System . CommandLine ;
22
20
using System . CommandLine . Invocation ;
23
21
using System . CommandLine . NamingConventionBinder ;
24
- using System . ComponentModel ;
25
22
using System . IO ;
26
23
using System . IO . Compression ;
27
24
using System . Linq ;
@@ -42,7 +39,6 @@ static int Main(string[] args)
42
39
new Option < bool > ( "--checked" , "Indicates whether to check for overflow and underflow." ) ,
43
40
new Option < bool > ( new [ ] { "-d" , "--debug" } , "Indicates whether to generate debugging information." ) ,
44
41
new Option < bool > ( "--assembly" , "Indicates whether to generate assembly." ) ,
45
- new Option < Options . GenerateArtifactsKind > ( "--generate-artifacts" , "Instruct the compiler how to generate artifacts." ) ,
46
42
new Option < bool > ( "--no-optimize" , "Instruct the compiler not to optimize the code." ) ,
47
43
new Option < bool > ( "--no-inline" , "Instruct the compiler not to insert inline code." ) ,
48
44
new Option < byte > ( "--address-version" , ( ) => ProtocolSettings . Default . AddressVersion , "Indicates the address version used by the compiler." )
@@ -181,76 +177,12 @@ private static int ProcessOutputs(Options options, string folder, CompilationCon
181
177
return 1 ;
182
178
}
183
179
Console . WriteLine ( $ "Created { path } ") ;
184
-
185
- if ( options . GenerateArtifacts != Options . GenerateArtifactsKind . None )
186
180
{
187
181
var artifact = manifest . Abi . GetArtifactsSource ( baseName ) ;
188
182
189
- if ( options . GenerateArtifacts == Options . GenerateArtifactsKind . SourceAndLibrary || options . GenerateArtifacts == Options . GenerateArtifactsKind . Source )
190
- {
191
- path = Path . Combine ( outputFolder , $ "{ baseName } .artifacts.cs") ;
192
- File . WriteAllText ( path , artifact ) ;
193
- Console . WriteLine ( $ "Created { path } ") ;
194
- }
195
-
196
- if ( options . GenerateArtifacts == Options . GenerateArtifactsKind . SourceAndLibrary || options . GenerateArtifacts == Options . GenerateArtifactsKind . Library )
197
- {
198
- try
199
- {
200
- // Try to compile the artifacts into a dll
201
-
202
- string coreDir = Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ! ;
203
-
204
- var syntaxTree = CSharpSyntaxTree . ParseText ( artifact ) ;
205
- var references = new MetadataReference [ ]
206
- {
207
- MetadataReference . CreateFromFile ( Path . Combine ( coreDir , "System.Runtime.dll" ) ) ,
208
- MetadataReference . CreateFromFile ( Path . Combine ( coreDir , "System.Runtime.InteropServices.dll" ) ) ,
209
- MetadataReference . CreateFromFile ( typeof ( object ) . Assembly . Location ) ,
210
- MetadataReference . CreateFromFile ( typeof ( DisplayNameAttribute ) . Assembly . Location ) ,
211
- MetadataReference . CreateFromFile ( typeof ( System . Numerics . BigInteger ) . Assembly . Location ) ,
212
- MetadataReference . CreateFromFile ( typeof ( UInt160 ) . Assembly . Location ) ,
213
- MetadataReference . CreateFromFile ( typeof ( SmartContract . Testing . SmartContract ) . Assembly . Location )
214
- } ;
215
-
216
- var compilation = CSharpCompilation . Create ( baseName , new [ ] { syntaxTree } , references ,
217
- new CSharpCompilationOptions (
218
- OutputKind . DynamicallyLinkedLibrary ,
219
- optimizationLevel : OptimizationLevel . Release ,
220
- platform : Platform . AnyCpu ,
221
- deterministic : true
222
- ) ) ;
223
-
224
- using var ms = new MemoryStream ( ) ;
225
- EmitResult result = compilation . Emit ( ms ) ;
226
-
227
- if ( ! result . Success )
228
- {
229
- var failures = result . Diagnostics . Where ( diagnostic =>
230
- diagnostic . IsWarningAsError ||
231
- diagnostic . Severity == DiagnosticSeverity . Error ) ;
232
-
233
- foreach ( var diagnostic in failures )
234
- {
235
- Console . Error . WriteLine ( "{0}: {1}" , diagnostic . Id , diagnostic . GetMessage ( ) ) ;
236
- }
237
- }
238
- else
239
- {
240
- ms . Seek ( 0 , SeekOrigin . Begin ) ;
241
-
242
- // Write dll
243
-
244
- path = Path . Combine ( outputFolder , $ "{ baseName } .artifacts.dll") ;
245
- File . WriteAllBytes ( path , ms . ToArray ( ) ) ;
246
- Console . WriteLine ( $ "Created { path } ") ;
247
- }
248
- }
249
- catch
250
- {
251
- Console . Error . WriteLine ( "Artifacts compilation error." ) ;
252
- }
253
- }
183
+ path = Path . Combine ( outputFolder , $ "{ baseName } .artifacts.cs") ;
184
+ File . WriteAllText ( path , artifact ) ;
185
+ Console . WriteLine ( $ "Created { path } ") ;
254
186
}
255
187
if ( options . Debug )
256
188
{
0 commit comments