Imported Upstream version 4.8.0.459

Former-commit-id: 2a5b9df2014f72665850c7f885e7aed54704a53a
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-01-19 14:22:10 +00:00
parent a355c1b831
commit e5cd25ff4f
725 changed files with 1215 additions and 107650 deletions

View File

@@ -59,7 +59,7 @@ namespace Mono.Cecil.Pdb {
static bool IsPortablePdb (string fileName)
{
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.None))
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
return IsPortablePdb (file);
}

View File

@@ -104,11 +104,17 @@ namespace Mono.Cecil.Pdb {
ReadSequencePoints (function, symbol);
if (function.scopes.Length > 1)
throw new NotSupportedException ();
else if (function.scopes.Length == 1)
if (!function.scopes.IsNullOrEmpty())
symbol.scope = ReadScopeAndLocals (function.scopes [0], symbol);
if (function.scopes.Length > 1) {
for (int i = 1; i < function.scopes.Length; i++) {
var s = ReadScopeAndLocals (function.scopes [i], symbol);
if (!AddScope (symbol.scope.Scopes, s))
symbol.scope.Scopes.Add (s);
}
}
return symbol;
}
@@ -133,6 +139,9 @@ namespace Mono.Cecil.Pdb {
parent.variables = new Collection<VariableDebugInformation> (scope.slots.Length);
foreach (PdbSlot slot in scope.slots) {
if (slot.flags == 1) // parameter names
continue;
var index = (int) slot.slot;
var variable = new VariableDebugInformation (index, slot.name);
if (slot.flags == 4)
@@ -157,6 +166,21 @@ namespace Mono.Cecil.Pdb {
return parent;
}
static bool AddScope (Collection<ScopeDebugInformation> scopes, ScopeDebugInformation scope)
{
foreach (var sub_scope in scopes) {
if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope))
return true;
if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) {
sub_scope.Scopes.Add (scope);
return true;
}
}
return false;
}
void ReadSequencePoints (PdbFunction function, MethodDebugInformation info)
{
if (function.lines == null)

View File

@@ -45,7 +45,8 @@ namespace Mono.Cecil.Pdb {
writer.OpenMethod (sym_token);
DefineSequencePoints (info.sequence_points);
if (!info.sequence_points.IsNullOrEmpty ())
DefineSequencePoints (info.sequence_points);
if (info.scope != null)
DefineScope (info.scope, info);

View File

@@ -147,6 +147,13 @@ namespace Mono.Cecil.Tests {
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
}
[Test]
public void EmptyEnumerable ()
{
TestModule ("empty-iterator.dll", module => {
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
}
[Test]
public void CreateMethodFromScratch ()
{