Permalink
Browse files

Fix MetadataTokenSearchStrategy.

  • Loading branch information...
siegfriedpammer committed Nov 28, 2018
1 parent 64e1bb6 commit 1dfd2bb9ac53c51a226a5b09644b624995eb525b
Showing with 29 additions and 1 deletion.
  1. +29 −1 ILSpy/Search/MetadataTokenSearchStrategy.cs
@@ -25,12 +25,40 @@ public override void Search(PEFile module)
if (searchTermToken.IsNil) return;
var typeSystem = module.GetTypeSystemOrNull();
if (typeSystem == null) return;
var metadataModule = (MetadataModule)typeSystem.MainModule;
int row = module.Metadata.GetRowNumber(searchTermToken);
switch (searchTermToken.Kind) {
case HandleKind.TypeDefinition:
var type = ((MetadataModule)typeSystem.MainModule).GetDefinition((TypeDefinitionHandle)searchTermToken);
if (row < 1 || row > module.Metadata.TypeDefinitions.Count)
break;
var type = metadataModule.GetDefinition((TypeDefinitionHandle)searchTermToken);
addResult(ResultFromEntity(type));
break;
case HandleKind.MethodDefinition:
if (row < 1 || row > module.Metadata.MethodDefinitions.Count)
break;
var method = metadataModule.GetDefinition((MethodDefinitionHandle)searchTermToken);
addResult(ResultFromEntity(method));
break;
case HandleKind.FieldDefinition:
if (row < 1 || row > module.Metadata.FieldDefinitions.Count)
break;
var field = metadataModule.GetDefinition((FieldDefinitionHandle)searchTermToken);
addResult(ResultFromEntity(field));
break;
case HandleKind.PropertyDefinition:
if (row < 1 || row > module.Metadata.PropertyDefinitions.Count)
break;
var property = metadataModule.GetDefinition((PropertyDefinitionHandle)searchTermToken);
addResult(ResultFromEntity(property));
break;
case HandleKind.EventDefinition:
if (row < 1 || row > module.Metadata.EventDefinitions.Count)
break;
var @event = metadataModule.GetDefinition((EventDefinitionHandle)searchTermToken);
addResult(ResultFromEntity(@event));
break;
}
}
}

0 comments on commit 1dfd2bb

Please sign in to comment.