Skip to content

Commit a083089

Browse files
authored
Update debugger packages, move to PortableInterop IMetadataImport (#80063)
As outlined in microsoft/ConcordExtensibilitySamples#124, the debugger will be breaking the public definition of `IMetadataImport`. This change updates the debugger package versions to latest versions in order to pick up the new definition under the `Microsoft.MetadataReader.PortableInterop` namespace and migrates the Roslyn usage off of the debugger definition in `Microsoft.MetadataReader.IMetadataImport`. This also updates the `DkmMetadataImportHolder` mock to expose the same property as the real class, ` Notably the new definition no longer uses `StringBuilder` marshalling, which should nominally improve performance.
2 parents bffc4a2 + 366f29b commit a083089

File tree

4 files changed

+75
-72
lines changed

4 files changed

+75
-72
lines changed

eng/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@
122122
VS Debugger
123123
-->
124124
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Contracts" Version="18.0.0-beta.25379.1" />
125-
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Engine-implementation" Version="17.13.1121201-preview" />
126-
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Metadata-implementation" Version="17.13.1121201-preview" />
125+
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Engine-implementation" Version="18.0.1082202-preview" />
126+
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Metadata-implementation" Version="18.0.1082202-preview" />
127127

128128
<!--
129129
VS .NET Runtime

src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.VisualStudio.Debugger.Evaluation;
1818
using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation;
1919
using Type = Microsoft.VisualStudio.Debugger.Metadata.Type;
20+
using Token = System.Reflection.Adds.Token;
2021

2122
namespace Microsoft.CodeAnalysis.ExpressionEvaluator
2223
{
@@ -182,23 +183,24 @@ string IDkmClrFullNameProvider2.GetClrNameForLocalVariable(DkmInspectionContext
182183
string IDkmClrFullNameProvider2.GetClrNameForField(DkmInspectionContext inspectionContext, DkmClrModuleInstance moduleInstance, int fieldToken)
183184
{
184185
using var importHolder = moduleInstance.GetMetaDataImportHolder();
186+
Token tkField = new Token(fieldToken);
185187

186188
// 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 _);
188190
const int S_OK = 0;
189191
if (hr != S_OK)
190192
{
191193
throw new ArgumentException("Invalid field token.", nameof(fieldToken));
192194
}
193195

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 _);
196198
if (hr != S_OK)
197199
{
198200
throw new DkmException((DkmExceptionCode)hr);
199201
}
200202

201-
string metadataName = sb.ToString();
203+
string metadataName = actualLength > 0 ? new string(szField, 0, (int)actualLength - 1) : string.Empty;
202204
return GetOriginalFieldName(metadataName);
203205
}
204206

0 commit comments

Comments
 (0)