Handle CryptoKeyFile from SolutionReader - #375
Conversation
| var originalFilePath = PathNormalizationUtil.NormalizePath(tuple.Item2.FilePath, kind); | ||
| var directory = Path.Combine(LogReaderState.CryptoKeyFileDirectory, index.ToString()); | ||
| Directory.CreateDirectory(directory); | ||
| var filePath = Path.Combine(directory, Path.GetFileName(originalFilePath)); | ||
|
|
||
| if (tuple.Item2.ContentHash is string contentHash) | ||
| { | ||
| File.WriteAllBytes(filePath, GetRawContentBytes(contentHash)); | ||
| } | ||
|
|
||
| compilationOptions = compilationOptions.WithCryptoKeyFile(filePath); |
There was a problem hiding this comment.
I think this is the best we can do with the code structured the way it is, but reading this I feel like I have the wrong abstraction layers in place. I think ideally this is the call that we should be making here
var filePath = PathNormalizationUtil.NormalizePath(tuple.Item2.FilePath, kind);Essentially the implementation of NormalizePath should look at the RawContentKind.CryptoKeyFile and decide to put it into the CryptoKeyFileDirectory. That is how we handle other content kind where we want to put content into specific directories (see ContentBuilder).
Doing that though would require us to thread more information into the reader. When creating the PathNormalizationUtil instance we need to have a derivation that captures LogReaderState and uses that. It's doable ... but I wanted to think about it for a bit.
Think we should take this as is and I will work this problem out in a separate PR.
| contentHash is not null ? ReadSourceText(kind, contentHash, hashAlgorithm) : null)); | ||
| break; | ||
| case RawContentKind.CryptoKeyFile: | ||
| HandleCryptoKeyFile(contentHash, filePath); |
There was a problem hiding this comment.
Why wasn't the code working before? We should be hitting this code, reading the content and dropping it to disk.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #375 +/- ##
==========================================
+ Coverage 95.76% 95.81% +0.04%
==========================================
Files 56 56
Lines 7819 7829 +10
Branches 915 917 +2
==========================================
+ Hits 7488 7501 +13
+ Misses 187 184 -3
Partials 144 144 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Preserve the 10.0.400 stdout-handle fix from PR jaredpar#375 while narrowing its blanket MSBuild environment filter to known unsafe variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c8d3934-edc7-4f26-a1fc-451749254212
No description provided.