Skip to content

Conversation

@shethaadit
Copy link
Contributor

Summary

This PR updates the example code for querying the .NET Framework version in the registry to resolve a CA2000 code analysis warning.

Changes:

  • Introduced a using block for the RegistryKey.OpenBaseKey call to ensure proper disposal of the base key.
  • Modified nested using blocks to manage the lifecycle of both baseKey and ndpKey in a resource-safe manner.
  • Ensures compliance with best practices for resource management in .NET.

Impact:

These changes prevent potential resource leaks and improve the robustness of the provided example code. This is particularly relevant for developers following the documentation to avoid introducing subtle bugs in their applications.

Fixes #44083

@shethaadit shethaadit requested review from a team and gewarren as code owners December 27, 2024 04:55
@dotnetrepoman dotnetrepoman bot added this to the December 2024 milestone Dec 27, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates PR is created by someone from the .NET community. label Dec 27, 2024
Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

Thanks @shethaadit

@gewarren gewarren merged commit 822a25b into dotnet:main Dec 27, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app-compat/subsvc community-contribution Indicates PR is created by someone from the .NET community. dotnet-framework/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource leak (or at least a CA2000 warning) in RegistryKey example

2 participants