|
17 | 17 | using Microsoft.VisualStudio.Debugger.Evaluation;
|
18 | 18 | using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation;
|
19 | 19 | using Type = Microsoft.VisualStudio.Debugger.Metadata.Type;
|
| 20 | +using Token = System.Reflection.Adds.Token; |
20 | 21 |
|
21 | 22 | namespace Microsoft.CodeAnalysis.ExpressionEvaluator
|
22 | 23 | {
|
@@ -182,23 +183,24 @@ string IDkmClrFullNameProvider2.GetClrNameForLocalVariable(DkmInspectionContext
|
182 | 183 | string IDkmClrFullNameProvider2.GetClrNameForField(DkmInspectionContext inspectionContext, DkmClrModuleInstance moduleInstance, int fieldToken)
|
183 | 184 | {
|
184 | 185 | using var importHolder = moduleInstance.GetMetaDataImportHolder();
|
| 186 | + Token tkField = new Token(fieldToken); |
185 | 187 |
|
186 | 188 | // Just get some of information about properties. Get rest later only if needed.
|
187 |
| - int hr = importHolder.Value.GetFieldProps(fieldToken, out _, null, 0, out var nameLength, out _, out _, out _, out _, out _, out _); |
| 189 | + int hr = importHolder.PortableValue.GetFieldProps(tkField, out _, null, 0, out uint nameLength, out _, out _, out _, out _, out _, out _); |
188 | 190 | const int S_OK = 0;
|
189 | 191 | if (hr != S_OK)
|
190 | 192 | {
|
191 | 193 | throw new ArgumentException("Invalid field token.", nameof(fieldToken));
|
192 | 194 | }
|
193 | 195 |
|
194 |
| - var sb = new StringBuilder(nameLength); |
195 |
| - hr = importHolder.Value.GetFieldProps(fieldToken, out _, sb, sb.Capacity, out _, out _, out _, out _, out _, out _, out _); |
| 196 | + char[] szField = new char[nameLength]; |
| 197 | + hr = importHolder.PortableValue.GetFieldProps(tkField, out _, szField, nameLength, out uint actualLength, out _, out _, out _, out _, out _, out _); |
196 | 198 | if (hr != S_OK)
|
197 | 199 | {
|
198 | 200 | throw new DkmException((DkmExceptionCode)hr);
|
199 | 201 | }
|
200 | 202 |
|
201 |
| - string metadataName = sb.ToString(); |
| 203 | + string metadataName = actualLength > 0 ? new string(szField, 0, (int)actualLength - 1) : string.Empty; |
202 | 204 | return GetOriginalFieldName(metadataName);
|
203 | 205 | }
|
204 | 206 |
|
|
0 commit comments