forked from neo-project/neo-devpack-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompilationOptions.cs
More file actions
89 lines (78 loc) · 2.89 KB
/
Copy pathCompilationOptions.cs
File metadata and controls
89 lines (78 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (C) 2015-2026 The Neo Project.
//
// CompilationOptions.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Neo.Compiler
{
public class CompilationOptions
{
[Flags]
public enum OptimizationType : byte
{
None = 0,
Basic = 1,
Experimental = 2,
All = Basic | Experimental
}
public enum DebugType : byte
{
/// <summary>
/// No debug
/// </summary>
None = 0,
/// <summary>
/// Strict NEP-19 standard
/// </summary>
Strict = 1,
/// <summary>
/// It will include Abi and compiler location information
/// </summary>
Extended = 2,
}
public NullableContextOptions Nullable { get; set; }
public DebugType Debug { get; set; } = DebugType.None;
public OptimizationType Optimize { get; set; } = OptimizationType.Basic;
public bool Checked { get; set; }
public bool NoInline { get; set; }
public byte AddressVersion { get; set; } = 0x35;
public string? BaseName { get; set; }
public string CompilerVersion { get; set; }
private CSharpParseOptions? parseOptions = null;
public bool SkipRestoreIfAssetsPresent { get; set; }
/// <summary>
/// Gets or sets whether the Neo contract analyzer suite runs before contract conversion.
/// </summary>
public bool RunAnalyzers { get; set; }
public CSharpParseOptions GetParseOptions()
{
if (parseOptions is null)
{
List<string> preprocessorSymbols = new();
if (Debug != DebugType.None) preprocessorSymbols.Add("DEBUG");
parseOptions = new CSharpParseOptions(languageVersion: LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols);
}
return parseOptions;
}
/// <summary>
/// Constructor
/// </summary>
public CompilationOptions()
{
Assembly assembly = Assembly.GetExecutingAssembly();
var titleAttribute = assembly.GetCustomAttribute<AssemblyTitleAttribute>()!;
var versionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!;
CompilerVersion = $"{titleAttribute.Title} {versionAttribute.InformationalVersion}";
}
}
}