dotnet / dotnet/roslyn

Revisit API design for `ICopilotCodeAnalysisService.IsAvailableAsync`

Open
#77,566 1 comment 0 reactions 1 assignee Claimed by @akhera99 View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Usage sample

```csharp
// Checks for feature flag
if (document.GetLanguageService() is not { } optionsService ||
await optionsService.IsImplementNotImplementedExceptionEnabledAsync().ConfigureAwait(false) is false)
{
return;
}

// Checks for service availability
if (document.GetLanguageService() is not { } copilotService ||
await copilotService.IsImplementNotImplementedExceptionsAvailableAsync(cancellationToken).ConfigureAwait(false) is false)
{
return;
}
```

or

https://github.com/dotnet/roslyn/blob/e65c6c8dfe7edddaad335b7d7eed34eef243300b/src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs#L78-L88

Would be good to revisit API usage for `IsAvailableAsync`.

Questions:
- Why do we have `IsAvailableAsync` on the `ICopilotCodeAnalysisService` and not `ICopilotCodeAnalysisService`?
- If it needs to remain there does it really make sense to inject that service into `ICopilotOptionsService`?
- In the above example, can't IsImplementNotImplementedExceptionEnabledAsync check if copilot is available?

/cc @akhera99 @genlu @CyrusNajmabadi
see https://github.com/dotnet/roslyn/pull/77299#discussion_r1992319589

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.