未验证 提交 cd72d61b 编写于 作者: H Heejae Chang 提交者: GitHub

made VS not crash on invalid dll reference (BadImageFormatException)....

made VS not crash on invalid dll reference (BadImageFormatException). especially for find all reference cache generation (#24452)
上级 5e3eec9a
......@@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Serialization;
using Microsoft.CodeAnalysis.Utilities;
......@@ -34,7 +35,7 @@ private static string GetMetadataNameWithoutBackticks(MetadataReader reader, Str
blobReader.CurrentPointer, backtickIndex);
}
}
private static MetadataId GetMetadataIdNoThrow(PortableExecutableReference reference)
{
try
......@@ -207,7 +208,7 @@ private struct MetadataInfoCreator : IDisposable
// The set of type definitions we've read out of the current metadata reader.
private readonly List<MetadataDefinition> _allTypeDefinitions;
public MetadataInfoCreator(
Solution solution, Checksum checksum, PortableExecutableReference reference, CancellationToken cancellationToken)
{
......@@ -253,24 +254,25 @@ internal SymbolTreeInfo Create()
try
{
_metadataReader = moduleMetadata.GetMetadataReader();
// First, walk all the symbols from metadata, populating the parentToChilren
// map accordingly.
GenerateMetadataNodes();
// Now, once we populated the initial map, go and get all the inheritance
// information for all the types in the metadata. This may refer to
// types that we haven't seen yet. We'll add those types to the parentToChildren
// map accordingly.
PopulateInheritanceMap();
// Clear the set of type definitions we read out of this piece of metadata.
_allTypeDefinitions.Clear();
}
catch (BadImageFormatException)
{
// any operation off metadata can throw BadImageFormatException
continue;
}
// First, walk all the symbols from metadata, populating the parentToChilren
// map accordingly.
GenerateMetadataNodes();
// Now, once we populated the initial map, go and get all the inheritance
// information for all the types in the metadata. This may refer to
// types that we haven't seen yet. We'll add those types to the parentToChildren
// map accordingly.
PopulateInheritanceMap();
// Clear the set of type definitions we read out of this piece of metadata.
_allTypeDefinitions.Clear();
}
var unsortedNodes = GenerateUnsortedNodes();
......@@ -339,7 +341,7 @@ private void GenerateMetadataNodes()
foreach (var kvp in definitionMap)
{
GenerateMetadataNodes(childNode,kvp.Key, kvp.Value);
GenerateMetadataNodes(childNode, kvp.Key, kvp.Value);
}
}
finally
......@@ -732,7 +734,7 @@ public MetadataDefinition(MetadataDefinitionKind kind, string name)
{
var typeName = GetMetadataNameWithoutBackticks(reader, definition.Name);
return new MetadataDefinition(MetadataDefinitionKind.Type,typeName)
return new MetadataDefinition(MetadataDefinitionKind.Type, typeName)
{
Type = definition
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册