Skip to content

Commit 82ac923

Browse files
committed
PreprocessorSymbolNames via CompilerCommand (if not F#).
1 parent 654ab1f commit 82ac923

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Buildalyzer/AnalyzerResult.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System;
21
using System.Collections;
3-
using System.Collections.Generic;
42
using System.IO;
5-
using System.Linq;
6-
using System.Text;
73
using Buildalyzer.Construction;
84
using Buildalyzer.Logging;
95
using Microsoft.Build.Framework;
@@ -31,6 +27,8 @@ public class AnalyzerResult : IAnalyzerResult
3127
private string[] _compilerArguments;
3228
private string _compilerFilePath;
3329

30+
public CompilerCommand CompilerCommand { get; private set; }
31+
3432
internal AnalyzerResult(string projectFilePath, AnalyzerManager manager, ProjectAnalyzer analyzer)
3533
{
3634
ProjectFilePath = projectFilePath;
@@ -64,7 +62,7 @@ internal AnalyzerResult(string projectFilePath, AnalyzerManager manager, Project
6462
public Guid ProjectGuid => _projectGuid;
6563

6664
/// <inheritdoc/>
67-
public string Command => _command;
65+
public string Command => CompilerCommand?.Text ?? _command;
6866

6967
/// <inheritdoc/>
7068
public string CompilerFilePath => _compilerFilePath;
@@ -121,6 +119,7 @@ public string GetProperty(string name) =>
121119
.ToArray() ?? Array.Empty<string>();
122120

123121
public string[] PreprocessorSymbols =>
122+
CompilerCommand?.PreprocessorSymbolNames.ToArray() ??
124123
_cscCommandLineArguments
125124
?.Where(x => x.Item1 is object && x.Item1.Equals("define", StringComparison.OrdinalIgnoreCase))
126125
.SelectMany(x => x.Item2.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
@@ -182,6 +181,7 @@ internal void ProcessCscCommandLine(string commandLine, bool coreCompile)
182181
return;
183182
}
184183
ProcessedCommandLine cmd = ProcessCscCommandLine(commandLine);
184+
CompilerCommand = Compiler.CommandLine.Parse(commandLine, CompilerLanguage.CSharp);
185185
_command = cmd.Command;
186186
_compilerFilePath = cmd.FileName;
187187
_compilerArguments = cmd.Arguments.ToArray();
@@ -269,6 +269,7 @@ internal void ProcessVbcCommandLine(string commandLine)
269269
}
270270
}
271271

272+
CompilerCommand = Compiler.CommandLine.Parse(commandLine, CompilerLanguage.VisualBasic);
272273
_command = cmd.Command;
273274
_compilerFilePath = cmd.FileName;
274275
_compilerArguments = cmd.Arguments.ToArray();

0 commit comments

Comments
 (0)