Conversation
PermissionDecisionApproveOnce is marked [Experimental], so GHCP001 is reported as an error and 'dotnet build ManualToolResume.cs' fails. Suppress it around the call the way dotnet/src/Client.cs and the docs already do.
There was a problem hiding this comment.
🟡 Changes recommended
The stable PermissionDecision.ApproveOnce() factory avoids the unnecessary experimental diagnostic suppression.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
| #pragma warning disable GHCP001 | ||
| await session2.Rpc.Permissions.HandlePendingPermissionRequestAsync( | ||
| permissionEvent.Data.RequestId, | ||
| new PermissionDecisionApproveOnce()); | ||
| #pragma warning restore GHCP001 |
| #pragma warning disable GHCP001 | ||
| await session2.Rpc.Permissions.HandlePendingPermissionRequestAsync( | ||
| permissionEvent.Data.RequestId, | ||
| new PermissionDecisionApproveOnce()); | ||
| #pragma warning restore GHCP001 |
Matches PermissionHandlers.cs and the documented discoverability entry point. The suppression stays because the PermissionDecision base class is itself [Experimental].
|
Thanks — I took the factory half of this and verified the rest, which did not hold up. Adopted: the sample now calls Kept: the suppression, because removing it does not build. The diagnostic simply moves from the derived type to the base type: $ dotnet build ManualToolResume.cs # factory, no pragma
ManualToolResume.cs(41,5): error GHCP001: 'GitHub.Copilot.Rpc.PermissionDecision'
is for evaluation purposes only and is subject to change or removal in future updates.The base class carries the attribute, so every member of the hierarchy is affected: // dotnet/src/Generated/Rpc.cs
[Experimental(Diagnostics.Experimental)]
[JsonPolymorphic(...)]
public partial class PermissionDecision
Current state builds clean: $ dotnet build ManualToolResume.cs # factory + pragma
exit 0, no errors or warnings |
dotnet/samples/ManualToolResume.csis a file-based app (it opens with#:project ../src/GitHub.Copilot.SDK.csproj), and it does not build.The sample calls
HandlePendingPermissionRequestAsyncwithnew PermissionDecisionApproveOnce(), and that type is marked experimental in the generated surface:ExperimentalAttributereports as an error unless suppressed, so the sample cannot be built or run as shipped.The change
Suppress the diagnostic around that one call, matching how the rest of the repository already handles it:
dotnet/src/Client.cswraps experimental usages in#pragma warning disable GHCP001/restorein several places.docs/features/usage-and-billing.mdtells readers to use exactly#pragma warning disable GHCP001or a project-level<NoWarn>GHCP001</NoWarn>.docs/setup/in-process-runtime.mdlists "Allow theGHCP001experimental API diagnostic" as the .NET requirement.I used the bare pragma with no explanatory comment, since that is the form used both in
Client.csand in the docs snippets.Verification
Both samples build after the change:
Chat.csalready built before this change; onlyManualToolResume.cswas affected. The build produces no warnings, and the diff is two added lines with no other edits.Context
Nothing builds the samples in CI, which is why this went unnoticed — the same gap behind #2648 (the Go samples module). I have not added CI coverage here either, since where that belongs seemed like your call.
For completeness, I checked the other two sample sets while I was at it and they are fine: the Node samples type-check against
nodejs/src, and every symbol the Python samples import resolves againstpython/copilot.