Skip to content
Permalink
Browse files

Don't perform DetectCatchWhenConditionBlocks transform when catchBloc…

…k.Variable.Type setter would throw an exception due to differing stack types.
  • Loading branch information...
dgrunwald committed Jun 9, 2019
1 parent d8ec095 commit ab4e05f783671aa012ed75f020d99d2b4ee98bcf
@@ -27,7 +27,11 @@ public class DetectCatchWhenConditionBlocks : IILTransform
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) {
@@ -300,6 +300,11 @@ IType IType.VisitChildren(TypeVisitor visitor)
{
return this;
}

public override string ToString()
{
return $"[MinimalCorlibType {typeCode}]";
}
}
}
}
@@ -26,7 +26,6 @@
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.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>();

0 comments on commit ab4e05f

Please sign in to comment.
You can’t perform that action at this time.