-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ResultProvider: Consume DkmClrModuleInstance.GetMetaDataImportHolder (#…
…76395) Previous to this change, the ResultProvider would use `DkmClrModuleInstance.GetMetaDataImport`, but did NOT use Marshal.ReleaseComObject on the result. This could result in locked files if the RCW took a long time to be finalized. This PR switches to use a new `GetMetaDataImportHolder` API that adds an IDisposable wrapper struct to take care of this cleanup. This PR requires VS 17.13 Build 35612.30 or newer.
- Loading branch information
1 parent
a3723c4
commit 095410a
Showing
4 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmMetadataImportHolder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Microsoft.MetadataReader; | ||
|
||
#nullable enable | ||
|
||
namespace Microsoft.VisualStudio.Debugger.Clr | ||
{ | ||
/// <summary> | ||
/// Wrapper around a <see cref="Microsoft.MetadataReader.IMetadataImport"/> interface | ||
/// reference that provides a easy way to release the reference to the underlying | ||
/// COM object. Instances of this struct should always be disposed. | ||
/// </summary> | ||
public readonly struct DkmMetadataImportHolder : IDisposable | ||
{ | ||
/// <summary> | ||
/// The underlying IMetaDataImport interface reference | ||
/// </summary> | ||
public IMetadataImport Value { get; } | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="DkmMetadataImportHolder"/>. | ||
/// </summary> | ||
/// <param name="value">[In] Implementation of IMetadataImport to wrap</param> | ||
public DkmMetadataImportHolder(IMetadataImport value) | ||
{ | ||
this.Value = value ?? throw new ArgumentNullException(nameof(value)); | ||
} | ||
|
||
void IDisposable.Dispose() | ||
{ | ||
// Mock implementation does nothing | ||
} | ||
} | ||
} |