Skip to content
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
5da3cc2
Copy all external linked files into MSBuildTaskHost
DustinCampbell Feb 2, 2026
b75f9a9
Separate $(DefineConstants) properties for net3* and net4*
DustinCampbell Feb 2, 2026
92d573b
MSBuildTaskHost: Move all polyfills to Polyfills folder
DustinCampbell Feb 2, 2026
04e8cd3
MSBuildTaskHost: Delete Polyfills\StringSyntaxAttribute.cs
DustinCampbell Feb 2, 2026
66effaf
MSBuildTaskHost: Remove FEATURE_LEGACY_GETCURRENTDIRECTORY
DustinCampbell Feb 2, 2026
acd2a60
MSBuildTaskHost: Remove FEATURE_LEGACY_GETFULLPATH
DustinCampbell Feb 2, 2026
423b462
MSBuildTaskHost: Remove FEATURE_ASSEMBLY_LOCATION
DustinCampbell Feb 2, 2026
1f14ea2
MSBuildTaskHost: Remove FEATURE_CULTUREINFO_GETCULTURES
DustinCampbell Feb 2, 2026
a705a93
MSBuildTaskHost: Remove FEATURE_APM
DustinCampbell Feb 2, 2026
8dd5bde
Remove FEATURE_* constants from .NET 3.5 builds unused by MSBuildTask…
DustinCampbell Feb 2, 2026
de8dfaf
MSBuildTaskHost: Remove FEATURE_PIPE_SECURITY and related constant
DustinCampbell Feb 2, 2026
2ce4a7b
MSBuildTaskHost: Remove FEATURE_SECURITY_PERMISSIONS
DustinCampbell Feb 2, 2026
d1ae88e
MSBuildTaskHost: Remove FEATURE_SECURITY_PRINCIPAL_WINDOWS
DustinCampbell Feb 2, 2026
b50526d
MSBuildTaskHost: Remove FEATURE_THREAD_ABORT
DustinCampbell Feb 2, 2026
b3a3380
MSBuildTaskHost: Remove FEATURE_VISUALSTUDIOSETUP
DustinCampbell Feb 2, 2026
7744be1
Remove Feature* properties from .NET 3.5 builds
DustinCampbell Feb 2, 2026
d61cf7c
MSBuildTaskHost: Remove FEATURE_REPORTFILEACCESSES
DustinCampbell Feb 2, 2026
aeb3e74
MSBuildTaskHost: Remove AppContext support from BuildEnvironmentHelper
DustinCampbell Feb 2, 2026
08b7d0c
MSBuildTaskHost: Remove VS Setup API from BuildEnviromentHelper
DustinCampbell Feb 2, 2026
228ec37
MSBuildTaskHost: Remove RUNTIME_TYPE_NETCORE code paths
DustinCampbell Feb 2, 2026
39ed041
MSBuildTaskHost: Remove a few unused types
DustinCampbell Feb 2, 2026
ecc03a3
MSBuildTaskHost: Remove NET35 disabled code blocks
DustinCampbell Feb 2, 2026
dd9c8a1
MSBuildTaskHost: Remove NET* disabled code blocks
DustinCampbell Feb 2, 2026
3a4dc40
MSBuildTaskHost: Remove BUILDINGAPPXTASKS code blocks
DustinCampbell Feb 2, 2026
d6e9d35
MSBuildTaskHost: Remove CLR2COMPATIBILITY disabled code blocks
DustinCampbell Feb 2, 2026
629bbbb
MSBuildTaskHost: Remove TASKHOST disabled code blocks
DustinCampbell Feb 2, 2026
fc3acde
MSBuildTaskHost: Remove FEATURE_ASSEMBLYLOADCONTEXT
DustinCampbell Feb 2, 2026
c89a8f4
MSBuildTaskHost: Remove FEATURE_PIPEOPTIONS_CURRENTUSERONLY
DustinCampbell Feb 2, 2026
652e1b0
MSBuildTaskHost: Remove FEATURE_NET35_TASKHOST
DustinCampbell Feb 2, 2026
f742101
MSBuildTaskHost: Remove NO_FRAMEWORK_IVT
DustinCampbell Feb 2, 2026
c13ff0f
MSBuildTaskHost: Remove FEATURE_APPDOMAIN
DustinCampbell Feb 2, 2026
73e68d4
MSBuildTaskHost: Remove OS runtime checks
DustinCampbell Feb 2, 2026
6db1744
MSBuildTaskHost: Remove uncalled members from FileUtilities.cs
DustinCampbell Feb 2, 2026
9a58fc9
MSBuildTaskHost: Reduce accessibility of FileUtilities.cs members
DustinCampbell Feb 2, 2026
422f462
MSBuildTaskHost: Merge FrameworkFileUtilities into FileUtilities
DustinCampbell Feb 2, 2026
aa924a0
MSBuildTaskHost: Remove uncalled members from XMakeAttributes.cs
DustinCampbell Feb 2, 2026
5b3f141
MSBuildTaskHost: Remove uncalled members from TypeLoader.cs
DustinCampbell Feb 2, 2026
8e9421a
MSBuildTaskHost: Remove NamedPipeUtil.cs
DustinCampbell Feb 2, 2026
1016f24
MSBuildTaskHost: Remove IBuildEngine3.cs and BuildEngineResult.cs
DustinCampbell Feb 2, 2026
76b9ef7
MSBuildTaskHost: Remove IExtendedBuildEventArgs
DustinCampbell Feb 2, 2026
e99fe71
MSBuildTaskHost: Remove SerializableMetadata.cs
DustinCampbell Feb 2, 2026
a679727
MSBuildTaskHost: Remove ImmutableDictionary
DustinCampbell Feb 2, 2026
3be3358
MSBuildTaskHost: Remove uncalled members from EnvironmentUtilities.cs
DustinCampbell Feb 2, 2026
98b305f
MSBuildTaskHost: Remove uncalled members from CollectionHelpers.cs
DustinCampbell Feb 2, 2026
a6aa438
MSBuildTaskHost: Remove Constants.cs
DustinCampbell Feb 2, 2026
a0f9fb8
MSBuildTaskHost: Remove uncalled members from ExceptionHandling.cs
DustinCampbell Feb 2, 2026
1694bde
MSBuildTaskHost: Remove uncalled members from ErrorUtilities.cs
DustinCampbell Feb 2, 2026
1cd4cc0
MSBuildTaskHost: Remove AssemblyUtilities.cs
DustinCampbell Feb 2, 2026
f93b9e0
MSBuildTaskHost: Remove uncalled members in NativeMethods.cs
DustinCampbell Feb 2, 2026
9cb0e1e
MSBuildTaskHost: Remove MSBuildNameIgnoringCaseComparer
DustinCampbell Feb 2, 2026
b3f7c25
MSBuildTaskHost: Replace ProcessorArchitectures with simple Is64Bit test
DustinCampbell Feb 2, 2026
3f8adee
MSBuildTaskHost: Remove XMakeAttributes.cs
DustinCampbell Feb 2, 2026
fe09045
MSBuildTaskHost: Trim unnecessary code out of BuildEnvironmentHelper.cs
DustinCampbell Feb 2, 2026
e86369b
MSBuildTaskHost: Remove more uncalled members from FileUtilities.cs
DustinCampbell Feb 2, 2026
8866a4c
MSBuildTaskHost: Use NetFx implementation of Path.Combine
DustinCampbell Feb 3, 2026
b5b7d54
MSBuildTaskHost: Remove uncalled members in Traits.cs
DustinCampbell Feb 3, 2026
0879e78
MSBuildTaskHost: Remove ChangeWaves
DustinCampbell Feb 3, 2026
5b7410a
MSBuildTaskHost: Remove BuildEnvironmentState
DustinCampbell Feb 3, 2026
dcb8aca
MSBuildTaskHost: Remove SupportOSPlatform attributes
DustinCampbell Feb 3, 2026
3250907
MSBuildTaskHost: Remove uncalled members in ResourceUtilities
DustinCampbell Feb 3, 2026
86fd3c4
MSBuildTaskHost: Remove ITaskItem2
DustinCampbell Feb 3, 2026
586c2c1
MSBuildTaskHost: Remove uncalled members from TaskParameterTaskItem
DustinCampbell Feb 3, 2026
20af332
MSBuildTaskHost: Remove TaskEngineAssemblyResolver
DustinCampbell Feb 3, 2026
cc7731f
MSBuildTaskHost: Remove AssemblyNameExtension and AssemblyNameComparer
DustinCampbell Feb 3, 2026
92f15fc
MSBuildTaskHost: Remove IFileSystem and related types
DustinCampbell Feb 3, 2026
c635ab6
MSBuildTaskHost: Remove AnsiDetector
DustinCampbell Feb 3, 2026
8fd687b
MSBuildTaskHost: Remove uncalled members from TranslationHelpers
DustinCampbell Feb 3, 2026
6bd8400
MSBuildTaskHost: Remove BinaryTranslator interning support
DustinCampbell Feb 3, 2026
407b75d
MSBuildTaskHost: Remove uncalled members from ITranslater
DustinCampbell Feb 3, 2026
65ff4fe
MSBuildTaskHost: Remove uncalled members from OutOfProcTaskHostNode
DustinCampbell Feb 3, 2026
d0e24c7
MSBuildTaskHost: Remove FrameworkErrorUtilities
DustinCampbell Feb 3, 2026
f6211c6
MSBuildTaskHost: Remove ResponseFileUsedEventArgs
DustinCampbell Feb 3, 2026
80650a0
MSBuildTaskHost: Simplify HandshakeOptions
DustinCampbell Feb 3, 2026
6875837
MSBuildTaskHost: Remove TaskHostParameters
DustinCampbell Feb 3, 2026
63278ab
MSBuildTaskHost: Merge NodeEndpointOutOfProcTaskHost
DustinCampbell Feb 3, 2026
e49bde6
MSBuildTaskHost: Merge OutOfProcTaskAppDomainWrapper
DustinCampbell Feb 3, 2026
7b01e69
MSBuildTaskHost: Remove OutOfProcTaskAppDomainWrapper.CancelTask
DustinCampbell Feb 3, 2026
4e930e2
MSBuildTaskHost: Remove MSBuildArchitecture and MSBuildRuntime
DustinCampbell Feb 3, 2026
bbdfdb1
MSBuildTaskHost: Don't use AssemblyLoadInfo
DustinCampbell Feb 4, 2026
848d79b
MSBuildTaskHost: Remove AssemblyLoadInfo
DustinCampbell Feb 4, 2026
ffa96f4
MSBuildTaskHost: Remove unused members and parameters from LoadedType
DustinCampbell Feb 4, 2026
fe8e104
MSBuildTaskHost: Remove RunInSTAAttribute
DustinCampbell Feb 4, 2026
b2062ac
MSBuildTaskHost: Remove HasSTAThreadAttribute & FEATURE_APARTMENT_STATE
DustinCampbell Feb 4, 2026
1a4be5f
MSBuildTaskHost: Clean up OutOfProcTaskAppDomainWrapper and *TaskResult
DustinCampbell Feb 4, 2026
c2cdf0b
MSBuildTaskHost: Remove BuildEnviromentHelper.TryFromVisualStudioProcess
DustinCampbell Feb 4, 2026
d868eba
MSBuildTaskHost: Avoid BuildEnvironmentHelper in OutOfProcTaskHostNode
DustinCampbell Feb 4, 2026
0d8a66f
MSBuildTaskHost: Remove uncalled members from CommunicationUtilities
DustinCampbell Feb 4, 2026
53b7826
Adjust Handshake salt calculation for MSBuildTaskHost
DustinCampbell Feb 4, 2026
471568c
MSBuildTaskHost: Remove BuildEnvironmentHelper
DustinCampbell Feb 4, 2026
2821ed7
MSBuildTaskHost: Remove uncalled members from FileUtilities
DustinCampbell Feb 4, 2026
b9a2e30
MSBuildTaskHost: Reorganize files and namespaces
DustinCampbell Feb 4, 2026
0fdc494
MSBuildTaskHost: Clean up and fix exception serialization
DustinCampbell Feb 5, 2026
32146e9
MSBuildTaskHost: Enable default items in project file
DustinCampbell Feb 5, 2026
3a92cf3
MSBuildTaskHost: Rework and prune string resources
DustinCampbell Feb 5, 2026
c4aa56d
MSBuildTaskHost: Clean up BinaryReader/WriterExtensions
DustinCampbell Feb 5, 2026
2a97a76
MSBuildTaskHost: Clean up BinaryTranslater, ITranslater, and *Helpers
DustinCampbell Feb 5, 2026
f07f4ce
MSBuildTaskHost: Clean up BufferedReadStream
DustinCampbell Feb 5, 2026
34fa5a7
MSBuildTaskHost: Clean up INode* interfaces and related types
DustinCampbell Feb 5, 2026
b367f7c
MSBuildTaskHost: Clean up InterningBinaryReader
DustinCampbell Feb 5, 2026
1189909
MSBuildTaskHost: Clean up LogMessagePacketBase and fix bug
DustinCampbell Feb 5, 2026
5a337fd
MSBuildTaskHost: Clean up NodeBuildComplete
DustinCampbell Feb 5, 2026
bff8b3c
MSBuildTaskHost: Clean up NodeEngineShutdownReason
DustinCampbell Feb 5, 2026
ea0e75a
MSBuildTaskHost: Clean up NodeShutdown
DustinCampbell Feb 5, 2026
52f148b
MSBuildTaskHost: Clean up TaskHostConfiguration
DustinCampbell Feb 5, 2026
5487183
MSBuildTaskHost: Clean up TaskHostTaskCancelled
DustinCampbell Feb 5, 2026
0db87d4
MSBuildTaskHost: Clean up TaskHostTaskComplete
DustinCampbell Feb 5, 2026
3a3db6d
MSBuildTaskHost: Clean up TaskParameter
DustinCampbell Feb 5, 2026
f64ad9d
MSBuildTaskHost: Clean up TaskParameterTypeVerifier
DustinCampbell Feb 5, 2026
7cfbb7d
MSBuildTaskHost: Clean up NodePacketFactory
DustinCampbell Feb 5, 2026
e2d0b7f
MSBuildTaskHost: Clean up ITranslatable
DustinCampbell Feb 5, 2026
6686d21
MSBuildTaskHost: Clean up NodeEndpointOutOfProcTaskHost
DustinCampbell Feb 6, 2026
98c1053
MSBuildTaskHost: Clean up CollectionHelpers
DustinCampbell Feb 6, 2026
ca756e3
MSBuildTaskHost: Clean up ConcurrentDictionary
DustinCampbell Feb 6, 2026
4f48280
MSBuildTaskHost: Clean up ConcurrentQueue
DustinCampbell Feb 6, 2026
ae8b9ae
MSBuildTaskHost: Clean up InternalErrorException
DustinCampbell Feb 6, 2026
ae0c6b1
MSBuildTaskHost: Clean up EnvironmentUtilities
DustinCampbell Feb 6, 2026
970cef6
MSBuildTaskHost: Clean up ErrorUtilities
DustinCampbell Feb 6, 2026
61b2259
MSBuildTaskHost: Clean up EscapingUtilities
DustinCampbell Feb 6, 2026
4b8def8
MSBuildTaskHost: Clean up ExceptionHandling
DustinCampbell Feb 6, 2026
15970ea
MSBuildTaskHost: Clean up FileUtilities
DustinCampbell Feb 6, 2026
daf60cd
MSBuildTaskHost: Merge FileUtilitiesRegex into FileUtilities
DustinCampbell Feb 6, 2026
bf875be
MSBuildTaskHost: Clean up Modifiers and NativeMethods
DustinCampbell Feb 6, 2026
c8c6b4b
MSBuildTaskHost: Clean up StringBuilderCache
DustinCampbell Feb 7, 2026
2ff2b90
MSBuildTaskHost: Clean up CommunicationUtilities
DustinCampbell Feb 9, 2026
d81c65f
MSBuildTaskHost: Clean up LoadedType
DustinCampbell Feb 9, 2026
a6c1e0a
MSBuildTaskHost: Clean up OutOfProcTaskHost
DustinCampbell Feb 9, 2026
dceb52c
MSBuildTaskHost: Clean up OutOfProcTaskHostNode
DustinCampbell Feb 9, 2026
e9d0198
MSBuildTaskHost: Clean up TaskLoader
DustinCampbell Feb 9, 2026
e110c06
MSBuildTaskHost: Clean up Traits
DustinCampbell Feb 9, 2026
e6812e5
MSBuildTaskHost: Clean up TypeLoader
DustinCampbell Feb 9, 2026
b0c015f
Add test that builds .NET Framework 3.5 WinForms project
DustinCampbell Feb 9, 2026
db64459
Apply Copilot CR feedback
DustinCampbell Feb 10, 2026
57622aa
Set <AppConfig> in Microsoft.Build.Engine.UnitTests.csproj
DustinCampbell Feb 10, 2026
069a045
Ensure .NET 3.5 test only runs on valid bootstrap layout
DustinCampbell Feb 10, 2026
e63c636
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 12, 2026
749460b
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 13, 2026
00764c8
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 18, 2026
27c5e9d
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 20, 2026
46709a5
Fix issue with MSBuildTaskHost handshake salt produced by client
DustinCampbell Feb 20, 2026
65650b7
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 23, 2026
2d288f4
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 25, 2026
b6073e3
Merge branch 'main' into isolate-taskhost
DustinCampbell Feb 27, 2026
ea52031
Change TaskHostLaunchArgs to more closely match NodeLaunchData
DustinCampbell Feb 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@
<Compile Include="..\Shared\UnitTests\CopyOnWriteDictionary_Tests.cs">
<Link>Collections\CopyOnWriteDictionary_Tests.cs</Link>
</Compile>
<Compile Include="..\Shared\UnitTests\ImmutableDictionary_Tests.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(MSBuildRuntimeType)' == 'Full'">
<Link>Collections\ImmutableDictionary_Tests.cs</Link>
</Compile>
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />

<None Include="..\Shared\UnitTests\App.config">
Expand Down
6 changes: 5 additions & 1 deletion src/Directory.BeforeCommon.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DefineConstants>$(DefineConstants);FEATURE_DEBUG_LAUNCH</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) Or $(TargetFramework.StartsWith('net3'))">
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);FEATURE_APARTMENT_STATE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_APM</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_APPDOMAIN</DefineConstants>
Expand Down Expand Up @@ -71,6 +71,10 @@
<DefineConstants>$(DefineConstants);FEATURE_MSCOREE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.StartsWith('net3'))">
<DefineConstants>$(DefineConstants);FEATURE_APARTMENT_STATE</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<!-- Useful for tests that need OS information as a constant -->
<DefineConstants Condition="$([MSBuild]::IsOSPlatform('windows'))">$(DefineConstants);TEST_ISWINDOWS</DefineConstants>
Expand Down
232 changes: 232 additions & 0 deletions src/MSBuildTaskHost/AssemblyLoadInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
// 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.Diagnostics;
using System.IO;
using Microsoft.Build.BackEnd;

#nullable disable

namespace Microsoft.Build.Shared
{
/// <summary>
/// This class packages information about how to load a given assembly -- an assembly can be loaded by either its assembly
/// name (strong or weak), or its filename/path.
/// </summary>
/// <remarks>
/// Uses factory to instantiate correct private class to save space: only one field is ever used of the two.
/// </remarks>
internal abstract class AssemblyLoadInfo : ITranslatable, IEquatable<AssemblyLoadInfo>
{
/// <summary>
/// This constructor initializes the assembly information.
/// </summary>
internal static AssemblyLoadInfo Create(string assemblyName, string assemblyFile)
{
ErrorUtilities.VerifyThrow((!string.IsNullOrEmpty(assemblyName)) || (!string.IsNullOrEmpty(assemblyFile)),
"We must have either the assembly name or the assembly file/path.");
ErrorUtilities.VerifyThrow((assemblyName == null) || (assemblyFile == null),
"We must not have both the assembly name and the assembly file/path.");

if (assemblyName != null)
{
return new AssemblyLoadInfoWithName(assemblyName);
}
else
{
return new AssemblyLoadInfoWithFile(assemblyFile);
}
}

/// <summary>
/// Gets the assembly's identity denoted by its strong/weak name.
/// </summary>
public abstract string AssemblyName
{
get;
}

/// <summary>
/// Gets the path to the assembly file.
/// </summary>
public abstract string AssemblyFile
{
get;
}

/// <summary>
/// Get the assembly location
/// </summary>
internal abstract string AssemblyLocation
{
get;
}

/// <summary>
/// Gets whether this assembly is an inline task assembly that should be loaded from bytes to avoid file locking.
/// </summary>
internal abstract bool IsInlineTask
{
get;
}

/// <summary>
/// Computes a hashcode for this assembly info, so this object can be used as a key into
/// a hash table.
/// </summary>
public override int GetHashCode()
{
return AssemblyLocation.GetHashCode();
}

public bool Equals(AssemblyLoadInfo other)
{
return Equals((object)other);
}

/// <summary>
/// Determines if two AssemblyLoadInfos are effectively the same.
/// </summary>
public override bool Equals(Object obj)
{
if (obj == null)
{
return false;
}

AssemblyLoadInfo otherAssemblyInfo = obj as AssemblyLoadInfo;

if (otherAssemblyInfo == null)
{
return false;
}

return (this.AssemblyName == otherAssemblyInfo.AssemblyName) && (this.AssemblyFile == otherAssemblyInfo.AssemblyFile);
}

public void Translate(ITranslator translator)
{
ErrorUtilities.VerifyThrow(translator.Mode == TranslationDirection.WriteToStream, "write only");
string assemblyName = AssemblyName;
string assemblyFile = AssemblyFile;
translator.Translate(ref assemblyName);
translator.Translate(ref assemblyFile);
}

public static AssemblyLoadInfo FactoryForTranslation(ITranslator translator)
{
string assemblyName = null;
string assemblyFile = null;
translator.Translate(ref assemblyName);
translator.Translate(ref assemblyFile);

return Create(assemblyName, assemblyFile);
}

/// <summary>
/// Assembly represented by name
/// </summary>
[DebuggerDisplay("{AssemblyName}")]
private sealed class AssemblyLoadInfoWithName : AssemblyLoadInfo
{
/// <summary>
/// Assembly name
/// </summary>
private string _assemblyName;

/// <summary>
/// Constructor
/// </summary>
internal AssemblyLoadInfoWithName(string assemblyName)
{
_assemblyName = assemblyName;
}

/// <summary>
/// Gets the assembly's identity denoted by its strong/weak name.
/// </summary>
public override string AssemblyName
{
get { return _assemblyName; }
}

/// <summary>
/// Gets the path to the assembly file.
/// </summary>
public override string AssemblyFile
{
get { return null; }
}

/// <summary>
/// Get the assembly location
/// </summary>
internal override string AssemblyLocation
{
get { return _assemblyName; }
}

/// <summary>
/// Gets whether this assembly is an inline task assembly.
/// Assembly names are never inline tasks.
/// </summary>
internal override bool IsInlineTask
{
get { return false; }
}
}

/// <summary>
/// Assembly info that uses a file path
/// </summary>
[DebuggerDisplay("{AssemblyFile}")]
private sealed class AssemblyLoadInfoWithFile : AssemblyLoadInfo
{
/// <summary>
/// Path to assembly
/// </summary>
private string _assemblyFile;

/// <summary>
/// Constructor
/// </summary>
internal AssemblyLoadInfoWithFile(string assemblyFile)
{
ErrorUtilities.VerifyThrow(Path.IsPathRooted(assemblyFile), "Assembly file path should be rooted");

_assemblyFile = assemblyFile;
}

/// <summary>
/// Gets the assembly's identity denoted by its strong/weak name.
/// </summary>
public override string AssemblyName
{
get { return null; }
}

/// <summary>
/// Gets the path to the assembly file.
/// </summary>
public override string AssemblyFile
{
get { return _assemblyFile; }
}

/// <summary>
/// Get the assembly location
/// </summary>
internal override string AssemblyLocation
{
get { return _assemblyFile; }
}

/// <summary>
/// Gets whether this assembly is an inline task assembly.
/// Detects inline tasks by checking if the file path ends with the inline task suffix.
/// </summary>
internal override bool IsInlineTask => false;
}
}
}
74 changes: 74 additions & 0 deletions src/MSBuildTaskHost/BinaryReaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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;

namespace Microsoft.Build.Shared
{
internal static class BinaryReaderExtensions
{
public static string? ReadOptionalString(this BinaryReader reader)
{
return reader.ReadByte() == 0 ? null : reader.ReadString();
}

public static int? ReadOptionalInt32(this BinaryReader reader)
{
return reader.ReadByte() == 0 ? null : reader.ReadInt32();
}

public static int Read7BitEncodedInt(this BinaryReader reader)
{
// Read out an Int32 7 bits at a time. The high bit
// of the byte when on means to continue reading more bytes.
int count = 0;
int shift = 0;
byte b;
do
{
// Check for a corrupted stream. Read a max of 5 bytes.
// In a future version, add a DataFormatException.
if (shift == 5 * 7) // 5 bytes max per Int32, shift += 7
{
throw new FormatException();
}

// ReadByte handles end of stream cases for us.
b = reader.ReadByte();
count |= (b & 0x7F) << shift;
shift += 7;
} while ((b & 0x80) != 0);
return count;
}

public static DateTime ReadTimestamp(this BinaryReader reader)
{
long timestampTicks = reader.ReadInt64();
DateTimeKind kind = (DateTimeKind)reader.ReadInt32();
var timestamp = new DateTime(timestampTicks, kind);
return timestamp;
}

public static unsafe Guid ReadGuid(this BinaryReader reader)
{
return new Guid(reader.ReadBytes(sizeof(Guid)));
}

public static Dictionary<string, TimeSpan> ReadDurationDictionary(this BinaryReader reader)
{
int count = reader.Read7BitEncodedInt();
var durations = new Dictionary<string, TimeSpan>(count);
for (int i = 0; i < count; i++)
{
string key = reader.ReadString();
TimeSpan value = TimeSpan.FromTicks(reader.ReadInt64());

durations.Add(key, value);
}

return durations;
}
}
}
Loading