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 System.Diagnostics;
6 
7 namespace System.Reflection.Metadata
8 {
9     public readonly struct ModuleReference
10     {
11         private readonly MetadataReader _reader;
12 
13         // Workaround: JIT doesn't generate good code for nested structures, so use RowId.
14         private readonly int _rowId;
15 
ModuleReferenceSystem.Reflection.Metadata.ModuleReference16         internal ModuleReference(MetadataReader reader, ModuleReferenceHandle handle)
17         {
18             Debug.Assert(reader != null);
19             Debug.Assert(!handle.IsNil);
20 
21             _reader = reader;
22             _rowId = handle.RowId;
23         }
24 
25         private ModuleReferenceHandle Handle
26         {
27             get { return ModuleReferenceHandle.FromRowId(_rowId); }
28         }
29 
30         public StringHandle Name
31         {
32             get { return _reader.ModuleRefTable.GetName(Handle); }
33         }
34 
GetCustomAttributesSystem.Reflection.Metadata.ModuleReference35         public CustomAttributeHandleCollection GetCustomAttributes()
36         {
37             return new CustomAttributeHandleCollection(_reader, Handle);
38         }
39     }
40 }
41