-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed source file from CodeTaskFactory and RoslynCodeTaskFactory in b…
…inlog (#9746) *Embed compilation file from CodeTaskFactory and RoslynCodeTaskFactory in binlog
- Loading branch information
1 parent
cd64b7b
commit a95f582
Showing
17 changed files
with
479 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ public enum BinaryLogRecordKind | |
String, | ||
TaskParameter, | ||
ResponseFileUsed, | ||
GeneratedFileUsed, | ||
AssemblyLoad, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Framework.UnitTests/GeneratedFileUsedEventArgs_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Microsoft.Build.Framework.UnitTests | ||
{ | ||
public class GeneratedFileUsedEventArgs_Tests | ||
{ | ||
[Fact] | ||
public void SerializationDeserializationTest() | ||
{ | ||
string filePath = "path"; | ||
string content = "content"; | ||
GeneratedFileUsedEventArgs arg = new(filePath, content); | ||
|
||
using MemoryStream stream = new MemoryStream(); | ||
using BinaryWriter bw = new BinaryWriter(stream); | ||
arg.WriteToStream(bw); | ||
|
||
stream.Position = 0; | ||
using BinaryReader br = new BinaryReader(stream); | ||
GeneratedFileUsedEventArgs argDeserialized = new(); | ||
int packetVersion = (Environment.Version.Major * 10) + Environment.Version.Minor; | ||
argDeserialized.CreateFromStream(br, packetVersion); | ||
|
||
argDeserialized.FilePath.ShouldBe(filePath); | ||
argDeserialized.Content.ShouldBe(content); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.IO; | ||
|
||
namespace Microsoft.Build.Framework | ||
{ | ||
/// <summary> | ||
/// Arguments for the generated file used event | ||
/// </summary> | ||
public class GeneratedFileUsedEventArgs : BuildMessageEventArgs | ||
{ | ||
public GeneratedFileUsedEventArgs() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GeneratedFileUsedEventArgs"/> class. | ||
/// </summary> | ||
/// | ||
public GeneratedFileUsedEventArgs(string filePath, string content) | ||
: base("", null, null, MessageImportance.Low) | ||
{ | ||
FilePath = filePath; | ||
Content = content; | ||
} | ||
|
||
/// <summary> | ||
/// The file path relative to the current project. | ||
/// </summary> | ||
public string? FilePath { set; get; } | ||
|
||
/// <summary> | ||
/// The content of the file. | ||
/// </summary> | ||
public string? Content { set; get; } | ||
|
||
internal override void WriteToStream(BinaryWriter writer) | ||
{ | ||
base.WriteToStream(writer); | ||
|
||
if (FilePath != null && Content != null) | ||
{ | ||
writer.Write(FilePath); | ||
writer.Write(Content); | ||
} | ||
} | ||
|
||
internal override void CreateFromStream(BinaryReader reader, int version) | ||
{ | ||
base.CreateFromStream(reader, version); | ||
|
||
FilePath = reader.ReadString(); | ||
Content = reader.ReadString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.