1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Internal.Metadata.NativeFormat.Writer; 6 7 using Cts = Internal.TypeSystem; 8 9 namespace ILCompiler.Metadata 10 { 11 /// <summary> 12 /// Controls metadata generation policy. Decides what types and members will get metadata. 13 /// </summary> 14 /// <remarks> 15 /// Thread safety: the implementers are required to be thread safe. 16 /// </remarks> 17 public interface IMetadataPolicy 18 { 19 /// <summary> 20 /// Returns true if the type should generate <see cref="TypeDefinition"/> metadata. If false, 21 /// the type will generate a <see cref="TypeReference"/> if required within the object graph. 22 /// </summary> 23 /// <param name="typeDef">Uninstantiated type definition to check.</param> GeneratesMetadata(Cts.MetadataType typeDef)24 bool GeneratesMetadata(Cts.MetadataType typeDef); 25 26 /// <summary> 27 /// Returns true if the method should generate <see cref="Method"/> metadata. If false, 28 /// the method should generate a <see cref="MemberReference"/> when needed. 29 /// </summary> 30 /// <param name="methodDef">Uninstantiated method definition to check.</param> GeneratesMetadata(Cts.MethodDesc methodDef)31 bool GeneratesMetadata(Cts.MethodDesc methodDef); 32 33 /// <summary> 34 /// Returns true if the field should generate <see cref="Field"/> metadata. If false, 35 /// the field should generate a <see cref="MemberReference"/> when needed. 36 /// </summary> 37 /// <param name="fieldDef">Uninstantiated field definition to check.</param> GeneratesMetadata(Cts.FieldDesc fieldDef)38 bool GeneratesMetadata(Cts.FieldDesc fieldDef); 39 40 /// <summary> 41 /// Returns true if a type should be blocked from generating any metadata. 42 /// Blocked interfaces are skipped from interface lists, and custom attributes referring to 43 /// blocked types are dropped from metadata. 44 /// </summary> IsBlocked(Cts.MetadataType typeDef)45 bool IsBlocked(Cts.MetadataType typeDef); 46 IsBlocked(Cts.MethodDesc methodDef)47 bool IsBlocked(Cts.MethodDesc methodDef); 48 49 /// <summary> 50 /// Return the Module that should be treated as defining the type. Typically implementations 51 /// will return typeDef.Module, but in some circumstances it may return a different value. 52 /// </summary> GetModuleOfType(Cts.MetadataType typeDef)53 Cts.ModuleDesc GetModuleOfType(Cts.MetadataType typeDef); 54 } 55 } 56