Skip to content

Commit

Permalink
Don't perform DetectCatchWhenConditionBlocks transform when catchBloc…
Browse files Browse the repository at this point in the history
…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 ab4e05f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Expand Up @@ -27,7 +27,11 @@ public class DetectCatchWhenConditionBlocks : IILTransform
public void Run(ILFunction function, ILTransformContext context) public void Run(ILFunction function, ILTransformContext context)
{ {
foreach (var catchBlock in function.Descendants.OfType<TryCatchHandler>()) { 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 // set exceptionType
catchBlock.Variable.Type = exceptionType; catchBlock.Variable.Type = exceptionType;
// Block entryPoint (incoming: 1) { // Block entryPoint (incoming: 1) {
Expand Down
Expand Up @@ -300,6 +300,11 @@ IType IType.VisitChildren(TypeVisitor visitor)
{ {
return this; return this;
} }

public override string ToString()
{
return $"[MinimalCorlibType {typeCode}]";
}
} }
} }
} }
5 changes: 1 addition & 4 deletions ILSpy/LoadedAssembly.cs
Expand Up @@ -26,7 +26,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.DebugInfo; using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.PdbProvider.Cecil; using ICSharpCode.Decompiler.PdbProvider.Cecil;
Expand All @@ -35,14 +34,12 @@
using ICSharpCode.ILSpy.DebugInfo; using ICSharpCode.ILSpy.DebugInfo;
using ICSharpCode.ILSpy.Options; using ICSharpCode.ILSpy.Options;


using static System.Reflection.Metadata.PEReaderExtensions;

namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
/// <summary> /// <summary>
/// Represents an assembly loaded into ILSpy. /// Represents an assembly loaded into ILSpy.
/// </summary> /// </summary>
[DebuggerDisplay("LoadedAssembly({shortName})")] [DebuggerDisplay("[LoadedAssembly {shortName}]")]
public sealed class LoadedAssembly public sealed class LoadedAssembly
{ {
internal static readonly ConditionalWeakTable<PEFile, LoadedAssembly> loadedAssemblies = new ConditionalWeakTable<PEFile, LoadedAssembly>(); internal static readonly ConditionalWeakTable<PEFile, LoadedAssembly> loadedAssemblies = new ConditionalWeakTable<PEFile, LoadedAssembly>();
Expand Down

0 comments on commit ab4e05f

Please sign in to comment.