Skip to content

Fix TaskParameterTaskItem serialization perf #11638

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions src/Build/Microsoft.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@
<Compile Include="..\Shared\CanonicalError.cs">
<Link>BackEnd\Components\RequestBuilder\IntrinsicTasks\CanonicalError.cs</Link>
</Compile>
<Compile Include="..\Shared\IConstrainedEqualityComparer.cs">
<Link>IConstrainedEqualityComparer.cs</Link>
</Compile>
<Compile Include="..\Shared\PropertyParser.cs">
<Link>BackEnd\Components\RequestBuilder\IntrinsicTasks\PropertyParser.cs</Link>
</Compile>
Expand Down Expand Up @@ -381,7 +378,6 @@
<Link>Collections\CopyOnWriteDictionary.cs</Link>
</Compile>
<Compile Include="Collections\CopyOnWritePropertyDictionary.cs" />
<Compile Include="..\Shared\MSBuildNameIgnoreCaseComparer.cs" />
<Compile Include="Collections\HashTableUtility.cs" />
<Compile Include="Collections\IConstrainableDictionary.cs" />
<Compile Include="Collections\ICopyOnWritePropertyDictionary.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace Microsoft.Build.Collections
/// Defines methods to support the comparison of objects for
/// equality over constrained inputs.
/// </summary>
#if TASKHOST
internal interface IConstrainedEqualityComparer<T> : IEqualityComparer<T>
#else
internal interface IConstrainedEqualityComparer<in T> : IEqualityComparer<T>
#endif
{
/// <summary>
/// Determines whether the specified objects are equal, factoring in the specified bounds when comparing <paramref name="y"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;

#nullable disable
Expand All @@ -22,7 +23,7 @@ internal class MSBuildNameIgnoreCaseComparer : IConstrainedEqualityComparer<stri
/// <summary>
/// The processor architecture on which we are running, but default it will be x86
/// </summary>
private static readonly NativeMethodsShared.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethodsShared.ProcessorArchitecture;
private static readonly NativeMethods.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethods.ProcessorArchitecture;

/// <summary>
/// The default immutable comparer instance.
Expand All @@ -46,12 +47,12 @@ public bool Equals(string compareToString, string constrainedString, int start,
{
if (lengthToCompare < 0)
{
ErrorUtilities.ThrowInternalError("Invalid lengthToCompare '{0}' {1} {2}", constrainedString, start, lengthToCompare);
EscapeHatches.ThrowInternalError("Invalid lengthToCompare '{0}' {1} {2}", constrainedString, start, lengthToCompare);
}

if (start < 0 || start > (constrainedString?.Length ?? 0) - lengthToCompare)
{
ErrorUtilities.ThrowInternalError("Invalid start '{0}' {1} {2}", constrainedString, start, lengthToCompare);
EscapeHatches.ThrowInternalError("Invalid start '{0}' {1} {2}", constrainedString, start, lengthToCompare);
}

if (ReferenceEquals(compareToString, constrainedString))
Expand All @@ -72,8 +73,8 @@ public bool Equals(string compareToString, string constrainedString, int start,
return false;
}

if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64)
&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
if ((s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.IA64)
&& (s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.ARM))
{
// The use of unsafe here is quite a bit faster than the regular
// mechanism in the BCL. This is because we can make assumptions
Expand Down Expand Up @@ -120,8 +121,8 @@ public int GetHashCode(string obj, int start, int length)
return 0; // per BCL convention
}

if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64)
&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
if ((s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.IA64)
&& (s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.ARM))
{
unsafe
{
Expand Down
4 changes: 0 additions & 4 deletions src/MSBuild/MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@
<Compile Include="..\Shared\FileUtilitiesRegex.cs">
<Link>FileUtilitiesRegex.cs</Link>
</Compile>
<Compile Include="..\Shared\IConstrainedEqualityComparer.cs">
<Link>IConstrainedEqualityComparer.cs</Link>
</Compile>
<Compile Include="..\Shared\QuotingUtilities.cs" />
<Compile Include="..\Shared\RegisteredTaskObjectCacheBase.cs">
<Link>RegisteredTaskObjectCacheBase.cs</Link>
Expand All @@ -90,7 +87,6 @@
<Compile Include="..\Shared\XMakeElements.cs" />
<Compile Include="..\Shared\CopyOnWriteDictionary.cs" />
<Compile Include="..\Shared\IKeyed.cs" />
<Compile Include="..\Shared\MSBuildNameIgnoreCaseComparer.cs" />
<Compile Include="..\Shared\NamedPipeUtil.cs" />
<Compile Include="..\Shared\ReadOnlyEmptyCollection.cs" />
<Compile Include="..\Shared\ReadOnlyEmptyDictionary.cs" />
Expand Down
2 changes: 2 additions & 0 deletions src/MSBuildTaskHost/MSBuildTaskHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@
<Compile Include="..\Shared\TaskHostTaskCancelled.cs" />
<Compile Include="..\Shared\TaskParameter.cs" />
<Compile Include="..\Shared\AssemblyNameExtension.cs" />
<Compile Include="..\Framework\IConstrainedEqualityComparer.cs" />
<Compile Include="..\Framework\MSBuildNameIgnoreCaseComparer.cs" />

<Compile Include="..\Shared\FileSystem\IFileSystem.cs" />
<Compile Include="..\Shared\FileSystem\FileSystems.cs" />
Expand Down
Loading