Browse Source

#1088: Add workaround for exception from Cecil

pull/1108/head
Siegfried Pammer 7 years ago
parent
commit
271379ec27
  1. 1
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs
  2. 8
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

1
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs

@ -29,6 +29,7 @@ using NUnit.Framework; @@ -29,6 +29,7 @@ using NUnit.Framework;
namespace ICSharpCode.Decompiler.Tests.TypeSystem
{
[TestFixture]
public class TypeSystemLoaderTests
{
static readonly Lazy<IUnresolvedAssembly> mscorlib = new Lazy<IUnresolvedAssembly>(

8
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -550,7 +550,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -550,7 +550,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (def is ICustomAttributeProvider cap) {
CollectAttributes(cap);
}
if (def is ISecurityDeclarationProvider sdp) {
if (def is ISecurityDeclarationProvider sdp && sdp.HasSecurityDeclarations) {
namespaces.Add("System.Security.Permissions");
CollectSecurityDeclarations(sdp);
}
@ -680,7 +680,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -680,7 +680,11 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
if (methodDef.HasBody) {
CollectNamespacesForDecompilation(methodDef.Body, namespaces, visited);
try {
CollectNamespacesForDecompilation(methodDef.Body, namespaces, visited);
} catch (Exception ex) {
Debug.WriteLine("Cecil failed to read method body: " + ex.ToString());
}
}
break;
}

Loading…
Cancel
Save