Skip to content

Commit

Permalink
Add support for configurable preprocessor directives
Browse files Browse the repository at this point in the history
  • Loading branch information
austinv900 committed Nov 19, 2023
1 parent 70f67b4 commit 176a030
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CSharp/CSharpLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public async Task Compile(int id, CompilerData data)
Stopwatch stopwatch = Stopwatch.StartNew();
_logger.LogInformation(Events.Compile, $"Starting compilation of job {id} | Total Plugins: {data.SourceFiles.Length}");
string details =
$"Settings[Encoding: {data.Encoding}, CSVersion: {data.CSharpVersion()}, Target: {data.OutputKind()}, Platform: {data.Platform()}, StdLib: {data.StdLib}, Debug: {data.Debug}]";
$"Settings[Encoding: {data.Encoding}, CSVersion: {data.CSharpVersion()}, Target: {data.OutputKind()}, Platform: {data.Platform()}, StdLib: {data.StdLib}, Debug: {data.Debug}, Preprocessor: {string.Join(", ", data.Preprocessor)}]";

if (Program.ApplicationLogLevel.MinimumLevel < LogEventLevel.Debug)
if (Program.ApplicationLogLevel.MinimumLevel <= LogEventLevel.Debug)
{
if (data.ReferenceFiles.Length > 0)
{
Expand Down Expand Up @@ -150,7 +150,7 @@ private async Task<CompilerMessage> SafeCompile(CompilerData data, CompilerMessa

Dictionary<CompilerFile, SyntaxTree> trees = new();
Encoding encoding = Encoding.GetEncoding(data.Encoding);
CSharpParseOptions options = new(data.CSharpVersion());
CSharpParseOptions options = new(data.CSharpVersion(), preprocessorSymbols: data.Preprocessor);
foreach (var source in data.SourceFiles)
{
string fileName = Path.GetFileName(source.Name);
Expand Down
1 change: 1 addition & 0 deletions src/ObjectStream/Data/CompilerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public CompilerData()
public CompilerLanguageVersion Version { get; set; }
public string Encoding { get; set; }
public bool Debug { get; set; }
public string[] Preprocessor { get; set; }

[NonSerialized]
public CompilerMessage Message;
Expand Down

0 comments on commit 176a030

Please sign in to comment.