Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Roslyn's file existence behavior for additionalfiles #217

Closed
DmitriyShepelev opened this issue Feb 18, 2025 · 1 comment · Fixed by #218
Closed

Respect Roslyn's file existence behavior for additionalfiles #217

DmitriyShepelev opened this issue Feb 18, 2025 · 1 comment · Fixed by #218

Comments

@DmitriyShepelev
Copy link

The complog throws an exception when files specified as additionalfiles don't exist, but the compilation will succeed. Sample stacktrace:

[6732] [001] [INFO]  Running binary log analysis.
[6732] [001] [INFO] Reading compiler calls from binary log <some-file-path>msbuild.binlog
[6732] [001] [ERROR]   Unhandled exception: System.Exception: Missing file, either build did not happen on this machine or the environment has changed: <some-file-path>stylecop.json
   at Basic.CompilerLog.Util.RoslynUtil.OpenBuildFileForRead(String filePath) in /home/runner/work/complog/complog/src/Basic.CompilerLog.Util/RoslynUtil.cs:line 265
   at Basic.CompilerLog.Util.RoslynUtil.GetSourceText(String filePath, SourceHashAlgorithm checksumAlgorithm, Boolean canBeEmbedded) in /home/runner/work/complog/complog/src/Basic.CompilerLog.Util/RoslynUtil.cs:line 51
   at Basic.CompilerLog.Util.BinaryLogReader.<ReadCompilationData>g__GetAdditionalTexts|30_6(<>c__DisplayClass30_0&) in /home/runner/work/complog/complog/src/Basic.CompilerLog.Util/BinaryLogReader.cs:line 238
   at Basic.CompilerLog.Util.BinaryLogReader.ReadCompilationData(CompilerCall compilerCall) in /home/runner/work/complog/complog/src/Basic.CompilerLog.Util/BinaryLogReader.cs:line 164
   at Basic.CompilerLog.Util.BinaryLogReader.ReadAllCompilationData(Func`2 predicate) in /home/runner/work/complog/complog/src/Basic.CompilerLog.Util/BinaryLogReader.cs:line 107
   at Semmle.Extraction.CSharp.Extractor.RunBinaryLogAnalysis(Stopwatch stopwatch, Options options, String binlogPath, ILogger logger, CanonicalPathCache canonicalPathCache, PathTransformer pathTransformer)
   at Semmle.Extraction.CSharp.Extractor.RunBinaryLogAnalysis(Stopwatch stopwatch, Options options, String[] binlogPaths, ILogger logger, CanonicalPathCache canonicalPathCache, PathTransformer pathTransformer)
   at Semmle.Extraction.CSharp.Extractor.Run(String[] args)

If the compilation succeeds, then I think it should be possible to obtain compilation data.

@jaredpar
Copy link
Owner

That error was meant to catch cases where people had stale builds on the machine and hence complog create on the binlog wasn't capturing what they expected it to. I agree though that need to mimic the compiler behavior here and be able to create functioning Compilation here with diagnostics. Likely need to rework more than just additional files though, guessing this incorrect pattern applies to a few other items like source files. Can still emit a warning in complog create to alert devs to the possible error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants