diff --git a/docs/features/refout.md b/docs/features/refout.md index 0bba8504a30d4..ef00d851719e9 100644 --- a/docs/features/refout.md +++ b/docs/features/refout.md @@ -56,7 +56,7 @@ The `CoreCompile` target supports a new output, called `IntermediateRefAssembly` The `Csc` task supports a new output, called `OutputRefAssembly`, which parallels the existing `OutputAssembly`. Both of those basically map to the `/refout` command-line parameter. -An additional task, called `CopyRefAssembly`, is provided along with the existing `Csc` task. It takes a `SourcePath` and a `DestinationPath` and generally copies the file from the source over to the destination. But if it can determine that the contents of those two files match (by comparing their MVIDs, see details below), then the destination file is left untouched. +An additional task, called `CopyRefAssembly`, is provided along with the existing `Csc` task. It takes a `SourcePath` and a `DestinationPath` and generally copies the file from the source over to the destination. But if it can determine that the contents of those two files match (by comparing their MVIDs), then the destination file is left untouched. As a side-note, `CopyRefAssembly` uses the same assembly resolution/redirection trick as `Csc` and `Vbc`, to avoid type loading problems with `System.IO.FileSystem`. @@ -68,7 +68,6 @@ With C# 7.1, the compiler now honours the `EmitOptions.IncludePrivateMembers` fl Method bodies aren't compiled when using `EmitMetadataOnly`. Even the diagnostic check for emitting methods lacking a body (`void M();`) is filtered from declaration diagnostics, so such code will successfully emit with `EmitMetadataOnly`. Later on, the `EmitOptions.TolerateErrors` flag will allow emitting error types as well. -`Emit` was modified to produce a new PE section called ".mvid" containing a copy of the MVID, when emitting ref assemblies. This makes it easy for `CopyRefAssembly` to extract and compare MVIDs from ref assemblies. Going back to the 4 driving scenarios: 1. For a regular compilation, `EmitMetadataOnly` is left to `false` and no `metadataPeStream` is passed into `Emit`. diff --git a/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs index a85ace3864376..35b0bef2eb92f 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs @@ -573,11 +573,9 @@ internal static void Main() verifyEntryPoint(output, expectZero: false); VerifyMethods(output, "C", new[] { "void C.Main()", "C..ctor()" }); - VerifyMvid(output, hasMvidSection: false); verifyEntryPoint(metadataOutput, expectZero: false); VerifyMethods(metadataOutput, "C", new[] { "void C.Main()", "C..ctor()" }); - VerifyMvid(metadataOutput, hasMvidSection: true); } void verifyEntryPoint(MemoryStream stream, bool expectZero) @@ -588,110 +586,6 @@ void verifyEntryPoint(MemoryStream stream, bool expectZero) } } - private class TestResourceSectionBuilder : ResourceSectionBuilder - { - public TestResourceSectionBuilder() - { - } - - protected override void Serialize(BlobBuilder builder, SectionLocation location) - { - builder.WriteInt32(0x12345678); - builder.WriteInt32(location.PointerToRawData); - builder.WriteInt32(location.RelativeVirtualAddress); - } - } - - private class TestPEBuilder : ManagedPEBuilder - { - public static readonly Guid s_mvid = Guid.Parse("a78fa2c3-854e-42bf-8b8d-75a450a6dc18"); - - public TestPEBuilder(PEHeaderBuilder header, - MetadataRootBuilder metadataRootBuilder, - BlobBuilder ilStream, - ResourceSectionBuilder nativeResources) - : base(header, metadataRootBuilder, ilStream, nativeResources: nativeResources) - { - } - - protected override ImmutableArray
CreateSections() - { - return base.CreateSections().Add( - new Section(".mvid", SectionCharacteristics.MemRead | - SectionCharacteristics.ContainsInitializedData | - SectionCharacteristics.MemDiscardable)); - } - - protected override BlobBuilder SerializeSection(string name, SectionLocation location) - { - if (name.Equals(".mvid", StringComparison.Ordinal)) - { - var sectionBuilder = new BlobBuilder(); - sectionBuilder.WriteGuid(s_mvid); - return sectionBuilder; - } - - return base.SerializeSection(name, location); - } - } - - [Fact] - public void MvidSectionNotFirst() - { - var ilBuilder = new BlobBuilder(); - var metadataBuilder = new MetadataBuilder(); - - var peBuilder = new TestPEBuilder( - PEHeaderBuilder.CreateLibraryHeader(), - new MetadataRootBuilder(metadataBuilder), - ilBuilder, - nativeResources: new TestResourceSectionBuilder()); - - var peBlob = new BlobBuilder(); - peBuilder.Serialize(peBlob); - - var peStream = new MemoryStream(); - peBlob.WriteContentTo(peStream); - - peStream.Position = 0; - using (var peReader = new PEReader(peStream)) - { - AssertEx.Equal(new[] { ".text", ".rsrc", ".reloc", ".mvid" }, - peReader.PEHeaders.SectionHeaders.Select(h => h.Name)); - - peStream.Position = 0; - var mvid = BuildTasks.MvidReader.ReadAssemblyMvidOrEmpty(peStream); - Assert.Equal(TestPEBuilder.s_mvid, mvid); - } - } - - /// - /// Extract the MVID using two different methods (PEReader and MvidReader) and compare them. - /// We only expect an .mvid section in ref assemblies. - /// - private void VerifyMvid(MemoryStream stream, bool hasMvidSection) - { - stream.Position = 0; - using (var reader = new PEReader(stream)) - { - var metadataReader = reader.GetMetadataReader(); - Guid mvidFromModuleDefinition = metadataReader.GetGuid(metadataReader.GetModuleDefinition().Mvid); - - stream.Position = 0; - var mvidFromMvidReader = BuildTasks.MvidReader.ReadAssemblyMvidOrEmpty(stream); - - Assert.NotEqual(Guid.Empty, mvidFromModuleDefinition); - if (hasMvidSection) - { - Assert.Equal(mvidFromModuleDefinition, mvidFromMvidReader); - } - else - { - Assert.Equal(Guid.Empty, mvidFromMvidReader); - } - } - } - [Fact] public void EmitRefAssembly_PrivatePropertySetter() { @@ -713,8 +607,6 @@ public class C VerifyMethods(output, "C", new[] { "System.Int32 C.k__BackingField", "System.Int32 C.PrivateSetter.get", "void C.PrivateSetter.set", "C..ctor()", "System.Int32 C.PrivateSetter { get; private set; }" }); VerifyMethods(metadataOutput, "C", new[] { "System.Int32 C.PrivateSetter.get", "C..ctor()", "System.Int32 C.PrivateSetter { get; }" }); - VerifyMvid(output, hasMvidSection: false); - VerifyMvid(metadataOutput, hasMvidSection: true); } } @@ -1218,20 +1110,6 @@ private static void CompareAssemblies(string sourceTemplate, string change1, str { AssertEx.NotEqual(image1.GetBuffer(), image2.GetBuffer(), message: $"Expecting difference for includePrivateMembers={includePrivateMembers} case, but they matched."); } - - var mvid1 = BuildTasks.MvidReader.ReadAssemblyMvidOrEmpty(image1); - var mvid2 = BuildTasks.MvidReader.ReadAssemblyMvidOrEmpty(image2); - - if (!includePrivateMembers) - { - Assert.NotEqual(Guid.Empty, mvid1); - Assert.Equal(expectMatch, mvid1 == mvid2); - } - else - { - Assert.Equal(Guid.Empty, mvid1); - Assert.Equal(Guid.Empty, mvid2); - } } #if NET472 diff --git a/src/Compilers/CSharp/Test/Emit/Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj b/src/Compilers/CSharp/Test/Emit/Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj index a3b0da3b6e01f..ff2aac7f0c43a 100644 --- a/src/Compilers/CSharp/Test/Emit/Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj +++ b/src/Compilers/CSharp/Test/Emit/Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj @@ -16,11 +16,6 @@ - - - Emit\MvidReader.cs - - diff --git a/src/Compilers/CSharp/Test/Emit2/Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj b/src/Compilers/CSharp/Test/Emit2/Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj index a3b0da3b6e01f..ff2aac7f0c43a 100644 --- a/src/Compilers/CSharp/Test/Emit2/Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj +++ b/src/Compilers/CSharp/Test/Emit2/Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj @@ -16,11 +16,6 @@ - - - Emit\MvidReader.cs - - diff --git a/src/Compilers/CSharp/Test/Emit3/Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj b/src/Compilers/CSharp/Test/Emit3/Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj index be883e4c0601a..cb44a22404362 100644 --- a/src/Compilers/CSharp/Test/Emit3/Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj +++ b/src/Compilers/CSharp/Test/Emit3/Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj @@ -16,11 +16,6 @@ - - - Emit\MvidReader.cs - - diff --git a/src/Compilers/CSharp/Test/EndToEnd/Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests.csproj b/src/Compilers/CSharp/Test/EndToEnd/Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests.csproj index 8ff71edc7a060..138aee22b9f37 100644 --- a/src/Compilers/CSharp/Test/EndToEnd/Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests.csproj +++ b/src/Compilers/CSharp/Test/EndToEnd/Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests.csproj @@ -17,9 +17,6 @@ - - Emit\MvidReader.cs - diff --git a/src/Compilers/Core/MSBuildTask/CopyRefAssembly.cs b/src/Compilers/Core/MSBuildTask/CopyRefAssembly.cs index 3fcf41687f4c8..5f6f36085a5d4 100644 --- a/src/Compilers/Core/MSBuildTask/CopyRefAssembly.cs +++ b/src/Compilers/Core/MSBuildTask/CopyRefAssembly.cs @@ -4,6 +4,8 @@ using System; using System.IO; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -96,11 +98,13 @@ private bool Copy() return true; } - private Guid ExtractMvid(string path) + private static Guid ExtractMvid(string path) { using (FileStream source = File.OpenRead(path)) + using (PEReader reader = new PEReader(source)) { - return MvidReader.ReadAssemblyMvidOrEmpty(source); + var metadataReader = reader.GetMetadataReader(); + return metadataReader.GetGuid(metadataReader.GetModuleDefinition().Mvid); } } } diff --git a/src/Compilers/Core/MSBuildTask/Directory.Build.props b/src/Compilers/Core/MSBuildTask/Directory.Build.props index 93f4f3aaab55e..c347dbb620adc 100644 --- a/src/Compilers/Core/MSBuildTask/Directory.Build.props +++ b/src/Compilers/Core/MSBuildTask/Directory.Build.props @@ -43,7 +43,6 @@ - diff --git a/src/Compilers/Core/MSBuildTask/MvidReader.cs b/src/Compilers/Core/MSBuildTask/MvidReader.cs deleted file mode 100755 index 530d579408c5e..0000000000000 --- a/src/Compilers/Core/MSBuildTask/MvidReader.cs +++ /dev/null @@ -1,212 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; - -namespace Microsoft.CodeAnalysis.BuildTasks -{ - public static class MvidReader - { - private static readonly Guid s_empty = Guid.Empty; - - public static Guid ReadAssemblyMvidOrEmpty(Stream stream) - { - return ReadAssemblyMvidOrEmpty(new BinaryReader(stream)); - } - - private static Guid ReadAssemblyMvidOrEmpty(BinaryReader reader) - { - // DOS Header: Magic number (2) - if (!ReadUInt16(reader, out ushort magicNumber) || magicNumber != 0x5a4d) // "MZ" - { - return s_empty; - } - - // DOS Header: Address of PE Signature (at 0x3C) - if (!MoveTo(0x3C, reader)) - { - return s_empty; - } - if (!ReadUInt32(reader, out uint pointerToPeSignature)) - { - return s_empty; - } - - // jump over the MS DOS Stub to the PE Signature - if (!MoveTo(pointerToPeSignature, reader)) - { - return s_empty; - } - - // PE Signature ('P' 'E' null null) - if (!ReadUInt32(reader, out uint peSig) || peSig != 0x00004550) - { - return s_empty; - } - - // COFF Header: Machine (2) - if (!Skip(2, reader)) - { - return s_empty; - } - - // COFF Header: NumberOfSections (2) - if (!ReadUInt16(reader, out ushort sections)) - { - return s_empty; - } - - // COFF Header: TimeDateStamp (4), PointerToSymbolTable (4), NumberOfSymbols (4) - if (!Skip(12, reader)) - { - return s_empty; - } - - // COFF Header: OptionalHeaderSize (2) - if (!ReadUInt16(reader, out ushort optionalHeaderSize)) - { - return s_empty; - } - - // COFF Header: Characteristics (2) - if (!Skip(2, reader)) - { - return s_empty; - } - - // Optional header - if (!Skip(optionalHeaderSize, reader)) - { - return s_empty; - } - - // Section headers - return FindMvidInSections(sections, reader); - } - - private static Guid FindMvidInSections(ushort count, BinaryReader reader) - { - for (int i = 0; i < count; i++) - { - // Section: Name (8) - if (!ReadBytes(reader, 8, out byte[]? name)) - { - return s_empty; - } - - if (name!.Length == 8 && name[0] == '.' && - name[1] == 'm' && name[2] == 'v' && name[3] == 'i' && name[4] == 'd' && name[5] == '\0') - { - // Section: VirtualSize (4) - if (!ReadUInt32(reader, out uint virtualSize) || virtualSize != 16) - { - // The .mvid section only stores a Guid - return s_empty; - } - - // Section: VirtualAddress (4), SizeOfRawData (4) - if (!Skip(8, reader)) - { - return s_empty; - } - - // Section: PointerToRawData (4) - if (!ReadUInt32(reader, out uint pointerToRawData)) - { - return s_empty; - } - - return ReadMvidSection(reader, pointerToRawData); - } - else - { - // Section: VirtualSize (4), VirtualAddress (4), SizeOfRawData (4), - // PointerToRawData (4), PointerToRelocations (4), PointerToLineNumbers (4), - // NumberOfRelocations (2), NumberOfLineNumbers (2), Characteristics (4) - if (!Skip(4 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 4, reader)) - { - return s_empty; - } - } - } - - return s_empty; - } - - private static Guid ReadMvidSection(BinaryReader reader, uint pointerToMvidSection) - { - if (!MoveTo(pointerToMvidSection, reader)) - { - return s_empty; - } - - if (!ReadBytes(reader, 16, out byte[]? guidBytes)) - { - return s_empty; - } - - return new Guid(guidBytes!); - } - - private static bool ReadUInt16(BinaryReader reader, out ushort output) - { - if (reader.BaseStream.Position + 2 >= reader.BaseStream.Length) - { - output = 0; - return false; - } - - output = reader.ReadUInt16(); - return true; - } - - private static bool ReadUInt32(BinaryReader reader, out uint output) - { - if (reader.BaseStream.Position + 4 >= reader.BaseStream.Length) - { - output = 0; - return false; - } - - output = reader.ReadUInt32(); - return true; - } - - private static bool ReadBytes(BinaryReader reader, int count, out byte[]? output) - { - if (reader.BaseStream.Position + count >= reader.BaseStream.Length) - { - output = null; - return false; - } - - output = reader.ReadBytes(count); - return true; - } - - private static bool Skip(int bytes, BinaryReader reader) - { - if (reader.BaseStream.Position + bytes >= reader.BaseStream.Length) - { - return false; - } - - reader.BaseStream.Seek(bytes, SeekOrigin.Current); - return true; - } - - private static bool MoveTo(uint position, BinaryReader reader) - { - if (position >= reader.BaseStream.Length) - { - return false; - } - - reader.BaseStream.Seek(position, SeekOrigin.Begin); - return true; - } - } -} diff --git a/src/Compilers/Core/MSBuildTaskTests/CopyRefAssemblyTests.cs b/src/Compilers/Core/MSBuildTaskTests/CopyRefAssemblyTests.cs index 53623813d216a..bbb451d323283 100644 --- a/src/Compilers/Core/MSBuildTaskTests/CopyRefAssemblyTests.cs +++ b/src/Compilers/Core/MSBuildTaskTests/CopyRefAssemblyTests.cs @@ -95,7 +95,7 @@ public void SourceNotAssemblyWithDestination() Assert.True(task.Execute()); - AssertEx.AssertEqualToleratingWhitespaceDifferences($$""" + AssertEx.AssertContainsToleratingWhitespaceDifferences($$""" Could not extract the MVID from "{{source.Path}}". Are you sure it is a reference assembly? Copying reference assembly from "{{source.Path}}" to "{{dest}}". """, diff --git a/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs b/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs deleted file mode 100755 index 5585cc6886379..0000000000000 --- a/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; -using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; -using System.Reflection.PortableExecutable; -using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis; - -namespace Microsoft.Cci -{ - /// - /// This PEBuilder adds an .mvid section. - /// - internal sealed class ExtendedPEBuilder - : ManagedPEBuilder - { - private const string MvidSectionName = ".mvid"; - public const int SizeOfGuid = 16; - - // When the section is built with a placeholder, the placeholder blob is saved for later fixing up. - private Blob _mvidSectionFixup = default(Blob); - - // Only include the .mvid section in ref assemblies - private readonly bool _withMvidSection; - - public ExtendedPEBuilder( - PEHeaderBuilder header, - MetadataRootBuilder metadataRootBuilder, - BlobBuilder ilStream, - BlobBuilder? mappedFieldData, - BlobBuilder? managedResources, - ResourceSectionBuilder? nativeResources, - DebugDirectoryBuilder? debugDirectoryBuilder, - int strongNameSignatureSize, - MethodDefinitionHandle entryPoint, - CorFlags flags, - Func, BlobContentId>? deterministicIdProvider, - bool withMvidSection) - : base(header, metadataRootBuilder, ilStream, mappedFieldData, managedResources, nativeResources, - debugDirectoryBuilder, strongNameSignatureSize, entryPoint, flags, deterministicIdProvider) - { - _withMvidSection = withMvidSection; - } - - protected override ImmutableArray
CreateSections() - { - var baseSections = base.CreateSections(); - - if (_withMvidSection) - { - var builder = ArrayBuilder
.GetInstance(baseSections.Length + 1); - - builder.Add(new Section(MvidSectionName, SectionCharacteristics.MemRead | - SectionCharacteristics.ContainsInitializedData | - SectionCharacteristics.MemDiscardable)); - - builder.AddRange(baseSections); - return builder.ToImmutableAndFree(); - } - else - { - return baseSections; - } - } - - protected override BlobBuilder SerializeSection(string name, SectionLocation location) - { - if (name.Equals(MvidSectionName, StringComparison.Ordinal)) - { - Debug.Assert(_withMvidSection); - return SerializeMvidSection(); - } - - return base.SerializeSection(name, location); - } - - internal BlobContentId Serialize(BlobBuilder peBlob, out Blob mvidSectionFixup) - { - var result = base.Serialize(peBlob); - mvidSectionFixup = _mvidSectionFixup; - return result; - } - - private BlobBuilder SerializeMvidSection() - { - var sectionBuilder = new BlobBuilder(); - - // The guid will be filled in later: - _mvidSectionFixup = sectionBuilder.ReserveBytes(SizeOfGuid); - var mvidWriter = new BlobWriter(_mvidSectionFixup); - mvidWriter.WriteBytes(0, _mvidSectionFixup.Length); - Debug.Assert(mvidWriter.RemainingBytes == 0); - - return sectionBuilder; - } - } -} diff --git a/src/Compilers/Core/Portable/PEWriter/PeWriter.cs b/src/Compilers/Core/Portable/PEWriter/PeWriter.cs index 8f5d3984b17b5..0ed587d414101 100644 --- a/src/Compilers/Core/Portable/PEWriter/PeWriter.cs +++ b/src/Compilers/Core/Portable/PEWriter/PeWriter.cs @@ -271,7 +271,7 @@ internal static bool WritePeToStream( var strongNameProvider = context.Module.CommonCompilation.Options.StrongNameProvider; var corFlags = properties.CorFlags; - var peBuilder = new ExtendedPEBuilder( + var peBuilder = new ManagedPEBuilder( peHeaderBuilder, metadataRootBuilder, emitBuilders.IlBlobBuilder, @@ -282,17 +282,16 @@ internal static bool WritePeToStream( CalculateStrongNameSignatureSize(context.Module, privateKeyOpt), entryPointHandle, corFlags, - peIdProvider, - metadataOnly && !context.IncludePrivateMembers); + peIdProvider); // This needs to force the backing builder to zero due to the issue writing COFF // headers. Can remove once this issue is fixed and we've moved to SRM with the // fix // https://github.com/dotnet/runtime/issues/99244 emitBuilders.PortableExecutableBlobBuilder = PooledBlobBuilder.GetInstance(zero: true); - var peContentId = peBuilder.Serialize(emitBuilders.PortableExecutableBlobBuilder, out Blob mvidSectionFixup); + var peContentId = peBuilder.Serialize(emitBuilders.PortableExecutableBlobBuilder); - PatchModuleVersionIds(mvidFixup, mvidSectionFixup, mvidStringFixup, peContentId.Guid); + PatchModuleVersionIds(mvidFixup, mvidStringFixup, peContentId.Guid); if (privateKeyOpt != null && corFlags.HasFlag(CorFlags.StrongNameSigned)) { @@ -332,7 +331,7 @@ internal static uint CalculateChecksum(BlobBuilder peBlob, Blob checksumBlob) })!; } - private static void PatchModuleVersionIds(Blob guidFixup, Blob guidSectionFixup, Blob stringFixup, Guid mvid) + private static void PatchModuleVersionIds(Blob guidFixup, Blob stringFixup, Guid mvid) { if (!guidFixup.IsDefault) { @@ -341,13 +340,6 @@ private static void PatchModuleVersionIds(Blob guidFixup, Blob guidSectionFixup, Debug.Assert(writer.RemainingBytes == 0); } - if (!guidSectionFixup.IsDefault) - { - var writer = new BlobWriter(guidSectionFixup); - writer.WriteGuid(mvid); - Debug.Assert(writer.RemainingBytes == 0); - } - if (!stringFixup.IsDefault) { var writer = new BlobWriter(stringFixup); diff --git a/src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs b/src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs index e48e2c1f4cf6e..e31b86451018d 100644 --- a/src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs +++ b/src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs @@ -8,9 +8,9 @@ using System.IO; using System.Linq; using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; using System.Security.Cryptography; -using Microsoft.Cci; using Microsoft.CodeAnalysis.Interop; using Roslyn.Utilities; @@ -173,7 +173,7 @@ internal override void SignFile(StrongNameKeys keys, string filePath) } } - internal override void SignBuilder(ExtendedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey) + internal override void SignBuilder(ManagedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey) { peBuilder.Sign(peBlob, content => SigningUtilities.CalculateRsaSignature(content, privateKey)); } diff --git a/src/Compilers/Core/Portable/StrongName/StrongNameProvider.cs b/src/Compilers/Core/Portable/StrongName/StrongNameProvider.cs index d17892595d3af..c6d855ebd5445 100644 --- a/src/Compilers/Core/Portable/StrongName/StrongNameProvider.cs +++ b/src/Compilers/Core/Portable/StrongName/StrongNameProvider.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; using System.Security.Cryptography; -using Microsoft.Cci; namespace Microsoft.CodeAnalysis { @@ -30,7 +30,7 @@ protected StrongNameProvider() /// /// Signs the contents of using and . /// - internal abstract void SignBuilder(ExtendedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey); + internal abstract void SignBuilder(ManagedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey); /// /// Create a for the provided information. diff --git a/src/Compilers/Test/Core/Compilation/TestDesktopStrongNameProvider.cs b/src/Compilers/Test/Core/Compilation/TestDesktopStrongNameProvider.cs index 67c2114c94dbb..921c9f8aa0b5c 100644 --- a/src/Compilers/Test/Core/Compilation/TestDesktopStrongNameProvider.cs +++ b/src/Compilers/Test/Core/Compilation/TestDesktopStrongNameProvider.cs @@ -7,8 +7,8 @@ using System; using System.Collections.Immutable; using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; using System.Security.Cryptography; -using Microsoft.Cci; using Microsoft.CodeAnalysis.Interop; namespace Microsoft.CodeAnalysis.Test.Utilities @@ -20,7 +20,7 @@ internal delegate void ReadKeysFromContainerDelegate( out ImmutableArray publicKey); internal ReadKeysFromContainerDelegate ReadKeysFromContainerFunc { get; set; } - internal Action SignBuilderFunc { get; set; } + internal Action SignBuilderFunc { get; set; } internal Action SignFileFunc { get; set; } internal Func GetStrongNameInterfaceFunc { get; set; } @@ -37,7 +37,7 @@ public TestDesktopStrongNameProvider(ImmutableArray keyFileSearchPaths = internal override void SignFile(StrongNameKeys keys, string filePath) => SignFileFunc(keys, filePath); - internal override void SignBuilder(ExtendedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey) => SignBuilderFunc(peBuilder, peBlob, privateKey); + internal override void SignBuilder(ManagedPEBuilder peBuilder, BlobBuilder peBlob, RSAParameters privateKey) => SignBuilderFunc(peBuilder, peBlob, privateKey); internal override IClrStrongName GetStrongNameInterface() => GetStrongNameInterfaceFunc(); }