Skip to content

Document breaking change: Generated WMI wrappers implement IDisposable - #56474

Open
SkyDevLab wants to merge 1 commit into
dotnet:mainfrom
SkyDevLab:docs/55779-wmi-wrappers-implement-idisposable
Open

SkyDevLab wants to merge 1 commit into
dotnet:mainfrom
SkyDevLab:docs/55779-wmi-wrappers-implement-idisposable

Conversation

@SkyDevLab

@SkyDevLab SkyDevLab commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Documents the .NET 11 RC 2 breaking change where generated strongly typed WMI collection and enumerator wrappers implement IDisposable to allow deterministic cleanup of COM-backed WMI resources.

Fixes #55779


Internal previews

File Preview link
docs/core/compatibility/11.md Learn preview
docs/core/compatibility/core-libraries/11/wmi-wrappers-implement-idisposable.md Learn preview
docs/core/compatibility/toc.yml Learn preview

Build report

@SkyDevLab
SkyDevLab requested review from a team and gewarren as code owners October 20, 2026 09:54
@dotnetrepoman dotnetrepoman Bot added this to the October 2026 milestone Oct 20, 2026
@dotnet-policy-service dotnet-policy-service Bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Oct 20, 2026
@@ -0,0 +1,57 @@
---
title: "Breaking change: Generated WMI wrappers implement IDisposable"
description: "Learn about the breaking change in .NET 11 RC 2 where generated strongly typed WMI collection and enumerator wrappers implement IDisposable."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove RC 2 everywhere except Version introduced section.

Comment on lines +56 to +57
- `System.Management.ManagementClass.GetStronglyTypedClassCode(bool, bool)` generated collection types
- `System.Management.ManagementClass.GetStronglyTypedClassCode(bool, bool)` generated enumerator types

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use xref links here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The examples need valid generated API calls, and migration guidance must explain wrapper regeneration.

2 open issues
What changed in this PR

Documents the .NET 11 RC 2 WMI wrapper disposal change in the compatibility guidance.

Changes:

  • Adds previous behavior, new disposal behavior, and migration recommendations.
  • Links the article from the .NET 11 compatibility index and table of contents.
File Description
docs/​core/​compatibility/​toc.yml Adds article navigation.
docs/​core/​compatibility/​core-libraries/​11/​wmi-wrappers-implement-idisposable.md Documents wrapper disposal and compatibility implications.
docs/​core/​compatibility/​11.md Lists the source and behavioral change.

Review effort: Balanced


```csharp
// The generated ServiceCollection type did not implement IDisposable.
Service.ServiceCollection services = service.SelectAll();

## Recommended action

Dispose generated collection and enumerator wrappers when they are no longer needed, preferably with `using` or `using var`.
@BillWagner
BillWagner requested review from a team and a balanced review from Copilot October 21, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Previously reported example-compilation and wrapper-regeneration issues remain unresolved in the supplied diff.

3 open issues

Review effort: Balanced


## Previous behavior

The collection and enumerator types emitted by <xref:System.Management.ManagementClass.GetStronglyTypedClassCode%2A> did not implement <xref:System.IDisposable>. A generated collection could not be used in a `using` statement, and consumers could not deterministically release the WMI resources held by its wrapped <xref:System.Management.ManagementObjectCollection> or enumerator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: Generated WMI wrappers implement IDisposable

3 participants