diff --git a/eng/Versions.props b/eng/Versions.props
index 0c5d9017d45581..c82f159232090c 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -88,6 +88,7 @@
1.2.0-beta.304
4.5.1
4.3.0
+ 5.0.0
5.0.0
4.8.2
4.5.0
diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj
index 291136d46ae916..c98ffb07608364 100644
--- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj
+++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj
@@ -16,11 +16,8 @@
Debug;Release;Checked
-
- 4.3.0
-
- 1.3.1
+ $(SystemCollectionsImmutableVersion)
diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj
index 82452cfa3e9c6d..86b9c06a6cf0d2 100644
--- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj
+++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj
@@ -26,9 +26,6 @@
-
- 4.3.0
-
$(SystemReflectionMetadataVersion)
diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs
index ef3eed5bb2f184..4df45e3065e0d3 100644
--- a/src/coreclr/tools/aot/crossgen2/Program.cs
+++ b/src/coreclr/tools/aot/crossgen2/Program.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Buffers.Binary;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
@@ -696,13 +697,13 @@ private void RunSingleCompilation(Dictionary inFilePaths, Instru
if (_commandLineOptions.CompositeKeyFile != null)
{
- ImmutableArray compositeStrongNameKey = File.ReadAllBytes(_commandLineOptions.CompositeKeyFile).ToImmutableArray();
+ byte[] compositeStrongNameKey = File.ReadAllBytes(_commandLineOptions.CompositeKeyFile);
if (!IsValidPublicKey(compositeStrongNameKey))
{
throw new Exception(string.Format(SR.ErrorCompositeKeyFileNotPublicKey));
}
- compositeImageSettings.PublicKey = compositeStrongNameKey;
+ compositeImageSettings.PublicKey = compositeStrongNameKey.ToImmutableArray();
}
//
@@ -954,7 +955,7 @@ public AlgorithmId(uint flags)
}
}
- private static readonly ImmutableArray s_ecmaKey = ImmutableArray.Create(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0 });
+ private static ReadOnlySpan s_ecmaKey => new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0 };
private const int SnPublicKeyBlobSize = 13;
@@ -968,15 +969,21 @@ public AlgorithmId(uint flags)
// From StrongNameInternal.cpp
// Checks to see if a public key is a valid instance of a PublicKeyBlob as
// defined in StongName.h
- internal static bool IsValidPublicKey(ImmutableArray blob)
+ internal static bool IsValidPublicKey(byte[] blob)
{
// The number of public key bytes must be at least large enough for the header and one byte of data.
- if (blob.IsDefault || blob.Length < s_publicKeyHeaderSize + 1)
+ if (blob.Length < s_publicKeyHeaderSize + 1)
{
return false;
}
- var blobReader = new BinaryReader(new MemoryStream(blob.ToArray()));
+ // Check for the ECMA key, which does not obey the invariants checked below.
+ if (blob.AsSpan().SequenceEqual(s_ecmaKey))
+ {
+ return true;
+ }
+
+ var blobReader = new BinaryReader(new MemoryStream(blob, writable: false));
// Signature algorithm ID
var sigAlgId = blobReader.ReadUInt32();
@@ -993,12 +1000,6 @@ internal static bool IsValidPublicKey(ImmutableArray blob)
return false;
}
- // Check for the ECMA key, which does not obey the invariants checked below.
- if (System.Linq.Enumerable.SequenceEqual(blob, s_ecmaKey))
- {
- return true;
- }
-
// The public key must be in the wincrypto PUBLICKEYBLOB format
if (publicKey != PublicKeyBlobId)
{