diff --git a/docs/features/refout.md b/docs/features/refout.md index 5dd6c37d5c6f6..9ab450afc9ffc 100644 --- a/docs/features/refout.md +++ b/docs/features/refout.md @@ -43,7 +43,6 @@ When the compiler produces documentation, the contents produced will match the A The compilation from the command-line will either produce both assemblies (implementation and ref) or neither. There is no "partial success" scenario. - ### CscTask/CoreCompile The `CoreCompile` target will support a new output, called `IntermediateRefAssembly`, which parallels the existing `IntermediateAssembly`. The `Csc` task will support a new output, called `OutputRefAssembly`, which parallels the existing `OutputAssembly`. diff --git a/src/Compilers/Core/MSBuildTask/MvidReader.cs b/src/Compilers/Core/MSBuildTask/MvidReader.cs index 7ceb3b43aedc7..53e517ede841d 100755 --- a/src/Compilers/Core/MSBuildTask/MvidReader.cs +++ b/src/Compilers/Core/MSBuildTask/MvidReader.cs @@ -23,17 +23,17 @@ private static Guid ReadAssemblyMvidOrEmpty(BinaryReader reader) return empty; } - // DOS Header: PE (2) - if (reader.ReadUInt16() != 0x5a4d) + // DOS Header: Magic number (2) + if (reader.ReadUInt16() != 0x5a4d) // "MZ" { return empty; } - // DOS Header: Start (58) - Skip(58, reader); + // DOS Header: Address of PE Signature (at 0x3C) + MoveTo(0x3C, reader); + uint lfanew = reader.ReadUInt32(); - // DOS Header: Address of PE Signature - MoveTo(reader.ReadUInt32(), reader); + MoveTo(lfanew, reader); // jump over the MS DOS Stub to the PE Signature // PE Signature ('P' 'E' null null) if (reader.ReadUInt32() != 0x00004550) @@ -65,6 +65,11 @@ private static Guid ReadAssemblyMvidOrEmpty(BinaryReader reader) private static Guid FindMvidInSections(ushort count, BinaryReader reader) { + if (count == 0) + { + return Guid.Empty; + } + // .mvid section must be first, if it's there // Section: Name (8) byte[] name = reader.ReadBytes(8); diff --git a/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs b/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs index e75878e0ede90..608d66faed3c2 100755 --- a/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs +++ b/src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs @@ -24,7 +24,7 @@ internal sealed class ExtendedPEBuilder private Blob _mvidSectionFixup = default(Blob); // Only include the .mvid section in ref assemblies - private bool _withMvidSection; + private readonly bool _withMvidSection; public ExtendedPEBuilder( PEHeaderBuilder header,