Add RegistryExtensions with ContainsSubKey#26
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/898a3064-5fea-48e3-b650-4b24cfb4a4a0 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot use SkippableFact to skip tests |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/5dbb3c70-db9e-4ef8-b986-01e93fcef6cc Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot please fix the build |
…ndard2.0 Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/662260f4-388d-4e05-a559-5a1a46909f25 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Ports a Windows Registry helper into PowerKit by introducing a RegistryKey extension that checks for the presence of a sub-key, along with tests to validate the behavior.
Changes:
- Add
RegistryExtensions.ContainsSubKey(string name)forMicrosoft.Win32.RegistryKey. - Add xUnit tests covering the “exists” and “does not exist” cases (guarded for Windows).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| PowerKit/Extensions/RegistryExtensions.cs | Adds a RegistryKey extension method to check whether a sub-key can be opened. |
| PowerKit.Tests/RegistryExtensionsTests.cs | Adds tests for the new extension method with a Windows-only runtime guard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
…-extensions # Conflicts: # Directory.Packages.props # PowerKit.Tests/PowerKit.Tests.csproj Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Done in b9d913e. Merged |
…s from PowerKit compilation Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/88654485-94be-46aa-9e01-a8f1ff3ef347 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…ot/add-registry-extensions Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/5c67cd9b-d34a-4468-bb36-48b678d073a9 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/01119e0b-66eb-4ea8-b4f0-43de8fe3218d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot no, I meant that it should already be polyfilled by PolyShim |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/227f4e25-02b2-418b-9c7d-8da2417d7b5f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Done in 86964ec. Removed the custom polyfill file — PolyShim's |
Ports
RegistryExtensionsfrom DotnetRuntimeBootstrapper into PowerKit.RegistryExtensions.ContainsSubKey(string name)— extendsRegistryKey; returnstrueif a sub-key with the given name can be opened. Marked[SupportedOSPlatform("windows")]on all active TFMs to satisfy CA1416. Opens and immediately disposes the sub-key to avoid a resource leak. Guarded with#if NET5_0_OR_GREATER || NETFRAMEWORKso the extension is available on both .NET 5+ and classic .NET Framework; the outer guard also ensures the source file compiles cleanly whenPowerKit.csprojtargetsnetstandard2.0without any extra package reference.SupportedOSPlatformAttributeis polyfilled by PolyShim on non-NET5+ TFMs (including NETFRAMEWORK), so no custom polyfill is needed.RegistryExtensionsTests— two tests (key exists / key does not exist); use[SkippableFact]+Skip.IfNot(OperatingSystem.IsWindows())so tests are properly reported as skipped on non-Windows CI.