Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullability - IApiKeyProvider.ProvideAsync should return Task<IApiKey?> #42

Open
skyflyer opened this issue Feb 22, 2024 · 3 comments
Open

Comments

@skyflyer
Copy link

Hello!

Thanks for the library 🙏!

Would you agree that it would be proper that the method declaration (ProvideAsync) in the IApiKeyProvider interface should return nullable value since it is explicitly checked in the handler? That way, no compiler warnings would be present (or escape hatches with !) 😄

@renerlemes
Copy link

renerlemes commented Jun 9, 2024

@skyflyer when the user is not authenticated by your implementation, it must return

return await Task.FromResult<IApiKey>(null);

@skyflyer
Copy link
Author

skyflyer commented Jun 9, 2024

Sure, but the compiler will warn, because you're returning null when the interface definition does not define that a return type is nullable. That's all I'm saying. :)

@renerlemes
Copy link

I didn't really understand your question, I understood that you wanted to know how to return the value.
Reading better now, I understand and agree that it should be nullable.

Sorry 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants