提交 e4122d45 编写于 作者: I Isaac Harwell

Moved the typeName assignment after checking for supported languages per:

https://github.com/dotnet/roslyn/issues/30449
上级 c32b6e73
......@@ -159,15 +159,21 @@ private static AnalyzerLoadFailureEventArgs CreateAnalyzerFailedArgs(Exception e
/// </summary>
/// <exception cref="BadImageFormatException">The PE image format is invalid.</exception>
/// <exception cref="IOException">IO error reading the metadata.</exception>
[PerformanceSensitive( "https://github.com/dotnet/roslyn/issues/30449" )]
private static ImmutableDictionary<string, ImmutableHashSet<string>> GetAnalyzerTypeNameMap(string fullPath, AttributePredicate attributePredicate)
{
using (var assembly = AssemblyMetadata.CreateFromFile(fullPath))
{
// This is longer than strictly necessary to avoid thrashing the GC with string allocations
// in the call to GetFullyQualifiedTypeNames. Specifically, this checks for the presence of
// supported languages prior to creating the type names.
var typeNameMap = from module in assembly.GetModules()
from typeDefHandle in module.MetadataReader.TypeDefinitions
let typeDef = module.MetadataReader.GetTypeDefinition(typeDefHandle)
let typeName = GetFullyQualifiedTypeName(typeDef, module.Module)
from supportedLanguage in GetSupportedLanguages(typeDef, module.Module, attributePredicate)
let typeDef = module.MetadataReader.GetTypeDefinition( typeDefHandle )
let supportedLanguages = GetSupportedLanguages( typeDef, module.Module, attributePredicate )
where supportedLanguages != null && supportedLanguages.Any()
let typeName = GetFullyQualifiedTypeName( typeDef, module.Module )
from supportedLanguage in supportedLanguages
group typeName by supportedLanguage;
return typeNameMap.ToImmutableDictionary(g => g.Key, g => g.ToImmutableHashSet());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册