Imported Upstream version 5.4.0.199

Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-09-25 16:57:44 +00:00
parent 536cd135cc
commit 5924117973
223 changed files with 3826 additions and 487 deletions

View File

@@ -684,6 +684,7 @@ namespace Mono.CompilerServices.SymbolWriter
byte[] hash;
bool creating;
bool auto_generated;
readonly string sourceFile;
public static int Size {
get { return 8; }
@@ -698,11 +699,17 @@ namespace Mono.CompilerServices.SymbolWriter
creating = true;
}
public SourceFileEntry (MonoSymbolFile file, string file_name, byte[] guid, byte[] checksum)
: this (file, file_name)
public SourceFileEntry (MonoSymbolFile file, string sourceFile, byte [] guid, byte [] checksum)
: this (file, sourceFile, sourceFile, guid, checksum)
{
}
public SourceFileEntry (MonoSymbolFile file, string fileName, string sourceFile, byte[] guid, byte[] checksum)
: this (file, fileName)
{
this.guid = guid;
this.hash = checksum;
this.sourceFile = sourceFile;
}
public byte[] Checksum {
@@ -719,29 +726,22 @@ namespace Mono.CompilerServices.SymbolWriter
if (guid == null)
guid = new byte[16];
if (hash == null)
hash = ComputeHash ();
if (hash == null) {
try {
using (FileStream fs = new FileStream (sourceFile, FileMode.Open, FileAccess.Read)) {
MD5 md5 = MD5.Create ();
hash = md5.ComputeHash (fs);
}
} catch {
hash = new byte [16];
}
}
bw.Write (guid);
bw.Write (hash);
bw.Write ((byte) (auto_generated ? 1 : 0));
}
private byte [] ComputeHash ()
{
if (!File.Exists (file_name))
return new byte [16];
try {
using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) {
MD5 md5 = MD5.Create ();
return md5.ComputeHash (fs);
}
} catch {
return new byte [16];
}
}
internal void Write (BinaryWriter bw)
{
bw.Write (Index);
@@ -758,7 +758,7 @@ namespace Mono.CompilerServices.SymbolWriter
int old_pos = (int) reader.BaseStream.Position;
reader.BaseStream.Position = DataOffset;
file_name = reader.ReadString ();
sourceFile = file_name = reader.ReadString ();
guid = reader.ReadBytes (16);
hash = reader.ReadBytes (16);
auto_generated = reader.ReadByte () == 1;
@@ -787,7 +787,7 @@ namespace Mono.CompilerServices.SymbolWriter
public bool CheckChecksum ()
{
try {
using (FileStream fs = new FileStream (file_name, FileMode.Open)) {
using (FileStream fs = new FileStream (sourceFile, FileMode.Open)) {
MD5 md5 = MD5.Create ();
byte[] data = md5.ComputeHash (fs);
for (int i = 0; i < 16; i++)