Browse Source

Don't perform DetectCatchWhenConditionBlocks transform when catchBlock.Variable.Type setter would throw an exception due to differing stack types.

pull/1556/head
Daniel Grunwald 7 years ago
parent
commit
ab4e05f783
  1. 6
      ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs
  2. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs
  3. 5
      ILSpy/LoadedAssembly.cs

6
ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs

@ -27,7 +27,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -27,7 +27,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public void Run(ILFunction function, ILTransformContext context)
{
foreach (var catchBlock in function.Descendants.OfType<TryCatchHandler>()) {
if (catchBlock.Filter is BlockContainer container && MatchCatchWhenEntryPoint(catchBlock.Variable, container, container.EntryPoint, out var exceptionType, out var exceptionSlot, out var whenConditionBlock)) {
if (catchBlock.Filter is BlockContainer container
&& MatchCatchWhenEntryPoint(catchBlock.Variable, container, container.EntryPoint,
out var exceptionType, out var exceptionSlot, out var whenConditionBlock)
&& exceptionType.GetStackType() == catchBlock.Variable.StackType)
{
// set exceptionType
catchBlock.Variable.Type = exceptionType;
// Block entryPoint (incoming: 1) {

5
ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs

@ -300,6 +300,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -300,6 +300,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
return this;
}
public override string ToString()
{
return $"[MinimalCorlibType {typeCode}]";
}
}
}
}

5
ILSpy/LoadedAssembly.cs

@ -26,7 +26,6 @@ using System.Runtime.CompilerServices; @@ -26,7 +26,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.PdbProvider.Cecil;
@ -35,14 +34,12 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation; @@ -35,14 +34,12 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy.DebugInfo;
using ICSharpCode.ILSpy.Options;
using static System.Reflection.Metadata.PEReaderExtensions;
namespace ICSharpCode.ILSpy
{
/// <summary>
/// Represents an assembly loaded into ILSpy.
/// </summary>
[DebuggerDisplay("LoadedAssembly({shortName})")]
[DebuggerDisplay("[LoadedAssembly {shortName}]")]
public sealed class LoadedAssembly
{
internal static readonly ConditionalWeakTable<PEFile, LoadedAssembly> loadedAssemblies = new ConditionalWeakTable<PEFile, LoadedAssembly>();

Loading…
Cancel
Save