/
LocalVariable.cs
36 lines (29 loc) · 1.28 KB
/
LocalVariable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
namespace System.Reflection.Metadata
{
/// <summary>
/// Local variable. Stored in debug metadata.
/// </summary>
/// <remarks>
/// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Reflection.Metadata/specs/PortablePdb-Metadata.md#localvariable-table-0x33.
/// </remarks>
public readonly struct LocalVariable
{
private readonly MetadataReader _reader;
// Workaround: JIT doesn't generate good code for nested structures, so use RowId.
private readonly int _rowId;
internal LocalVariable(MetadataReader reader, LocalVariableHandle handle)
{
Debug.Assert(reader != null);
Debug.Assert(!handle.IsNil);
_reader = reader;
_rowId = handle.RowId;
}
private LocalVariableHandle Handle => LocalVariableHandle.FromRowId(_rowId);
public LocalVariableAttributes Attributes => _reader.LocalVariableTable.GetAttributes(Handle);
public int Index => _reader.LocalVariableTable.GetIndex(Handle);
public StringHandle Name => _reader.LocalVariableTable.GetName(Handle);
}
}