Skip to content

Commit

Permalink
Fix #2197: .NET 5 RC2: "Analyze/Used By" throws BadImageFormatException
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Oct 23, 2020
1 parent 4e07c95 commit 1a1ad98
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ILSpy/Analyzers/Builtin/TypeUsedByAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection.Metadata;

Expand Down Expand Up @@ -217,7 +219,17 @@ void ScanMethodBody(TypeDefinitionUsedVisitor visitor, IMethod method, MethodBod

if (!methodBody.LocalSignature.IsNil)
{
foreach (var type in module.DecodeLocalSignature(methodBody.LocalSignature, genericContext))
ImmutableArray<IType> localSignature;
try
{
localSignature = module.DecodeLocalSignature(methodBody.LocalSignature, genericContext);
}
catch (BadImageFormatException)
{
// Issue #2197: ignore invalid local signatures
localSignature = ImmutableArray<IType>.Empty;
}
foreach (var type in localSignature)
{
type.AcceptVisitor(visitor);

Expand Down

0 comments on commit 1a1ad98

Please sign in to comment.