-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Remove nullable disable from aws #312
Remove nullable disable from aws #312
Conversation
Codecov Report
@@ Coverage Diff @@
## main #312 +/- ##
===================================
- Coverage 85% 85% -1%
===================================
Files 77 77
Lines 2195 2199 +4
Branches 309 313 +4
===================================
Hits 1873 1873
Misses 233 233
- Partials 89 93 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -17,7 +16,7 @@ namespace SixLabors.ImageSharp.Web.Caching.AWS; | |||
public class AWSS3StorageCache : IImageCache | |||
{ | |||
private readonly IAmazonS3 amazonS3Client; | |||
private readonly string bucket; | |||
private readonly string? bucket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do a guard check for the bucket name and make this non-nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is non nullable. But to achieve this we have the ugly hack with = null! in the options :(
|
||
/// <inheritdoc/> | ||
public string BucketName { get; set; } | ||
public string BucketName { get; set; } = null!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should switch to get; init;
for our options types to avoid these kinds of hacks. (We're .NET 6)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes no difference. Init does not mean that he must set it. It just says that it can not be changed after constructing.
For your desired behavior we need the required keyword and that is net7...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right (we keep having this conversation 🤣)
I do thoink for .NET 6 though, options-types should use this pattern to enforce immutability.
3b602a5
to
7ee9e16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Thanks!
Prerequisites
Description