コード例 #1
0
 private static IReadOnlyDictionary<AnonymousTypeKey, AnonymousTypeValue> GetAnonymousTypeMap(
     MetadataReader reader,
     Symbols.Metadata.PE.MetadataDecoder metadataDecoder)
 {
     var result = new Dictionary<AnonymousTypeKey, AnonymousTypeValue>();
     foreach (var handle in reader.TypeDefinitions)
     {
         var def = reader.GetTypeDefinition(handle);
         if (!def.Namespace.IsNil)
         {
             continue;
         }
         if (!reader.StringStartsWith(def.Name, GeneratedNames.AnonymousNamePrefix))
         {
             continue;
         }
         var metadataName = reader.GetString(def.Name);
         short arity;
         var name = MetadataHelpers.InferTypeArityAndUnmangleMetadataName(metadataName, out arity);
         int index;
         if (GeneratedNames.TryParseAnonymousTypeTemplateName(name, out index))
         {
             var builder = ArrayBuilder<string>.GetInstance();
             if (TryGetAnonymousTypeKey(reader, def, builder))
             {
                 var type = (NamedTypeSymbol)metadataDecoder.GetTypeOfToken(handle);
                 var key = new AnonymousTypeKey(builder.ToImmutable());
                 var value = new AnonymousTypeValue(name, index, type);
                 result.Add(key, value);
             }
             builder.Free();
         }
     }
     return result;
 }