-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Embed source file from CodeTaskFactory and RoslynCodeTaskFactory in binlog #9746
Embed source file from CodeTaskFactory and RoslynCodeTaskFactory in binlog #9746
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: this is doing what the bug asked for, which is logging the .cs
file if it was separate. Looking at it, I wonder if we should try to do one better and embed the generated source file too, regardless of where the C# came from--that is, log the file we tried to compile instead of the source.
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
… Full fail or not
…s Full fail or not" This reverts commit aea4ee7.
… Windows Full fail or not" This reverts commit 601d3d1.
…os Full fail or not" This reverts commit 8021d78.
This reverts commit cf859ea.
…and Windos Full fail or not"" This reverts commit 9a55dd9.
@rainersigwald , I agree that logging the generated file would improve debuggability. However, on the second thought wouldn't that be redundant because the code is already in the .csproj file? And what about Type "Fragment" and "Method"? <Task>
<Code Type="Class" Language="cs">
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class MyTask : Microsoft.Build.Utilities.Task
{
public override bool Execute()
{
Log.LogMessage(MessageImportance.High, "MyTask has been executed. The value of StringComparison is: " + StringComparison);
return true;
}
}
</Code>
</Task> |
I think logging the generated file for Agreed that if you have 100% of the code in the project there's no need to log it redundantly. |
There are some strange fails on Windows Full and Windows Core (Now it is only Windows Full and I didn't change the code). The error message is:
Given the error message, my guess was that the unexpected error could be thrown while the execution of the new tests. So, I removed the tests to see if Windows Full and Windows Core will fail again, and they failed again. When reverting the changes back now Windows Core passes and Windows Full not. @rainersigwald , @ladipro what do you think might be the problem? |
…-compilation-file.tmp 2. use helper for tests to reduce code repetition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a few comments inline. Overall, I'm wondering if the complexity added with IHasProjectFullPath
is really needed. If the paths persisted in binlog were relative or just file names, presumably viewing the binlog wouldn't be hampered. Worst case if somebody needed full paths, they could be trivially reconstructed at binlog read time.
src/Tasks.UnitTests/CodeTaskFactoryEmbeddedFileInBinlogTestHelper.cs
Outdated
Show resolved
Hide resolved
update version in BinaryLogger;
… relative file path inside BinaryLogger
Thanks @ladipro! I investigated if it is possible to get the full path of the file relative to the current project inside of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
Before signing off I'd want to see a sanity test of NodePackets translations (just a simple addition to existing test) and possibly moving the serialization logic to the owning type (which will allow getting rid of the Serialization attribute)
…edFileUsedEventArgs; add node packets test cases for new event args
skip GeneratedFileUsedEventArgs in TaskFactoryLoggingHost.IsEventSerializable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid feature with solid tests - ship it! :-)
Fixes #9686
Context
See more details in the issue description.
In this PR I made changes to embed the generated file that is used for compilation from
CodeTaskFactory
andRoslynCodeTaskFactory
. It could be the source file or an actual generated file (like fromFragment
).Because there is a race between embedding the generated file and deleting it, instead I save its contents and use the existing method
AddFileFromMemory
to embed it.The file is embedded in binlog as {projectDirectory}/{guid}-{taskName}-compilation-file.tmp
Changes Made
Introduced new event args for embedding generated file in binlog
GeneratedFileUsedEventArgs
similar toResponseFileUsedEventArgs
Introduced new method for the logger that is used for tasks:
Testing
Added unit tests and tested manually.
Notes