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

Remove nullable disable from aws #312

Merged

Conversation

stefannikolei
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #312 (bbf7f47) into main (e13e8af) will decrease coverage by 1%.
The diff coverage is 73%.

@@         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     
Flag Coverage Δ
unittests 85% <73%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...geSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs 31% <ø> (ø)
...oviders.AWS/Resolvers/AWSS3StorageCacheResolver.cs 100% <ø> (ø)
...oviders.AWS/Providers/AWSS3StorageImageProvider.cs 58% <14%> (-9%) ⬇️
...arp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs 78% <100%> (ø)
....Providers.AWS/Caching/AWSS3StorageCacheOptions.cs 85% <100%> (ø)
....AWS/Providers/AWSS3StorageImageProviderOptions.cs 87% <100%> (ø)
...oviders.AWS/Resolvers/AWSS3StorageImageResolver.cs 92% <100%> (ø)

... 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;
Copy link
Member

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.

Copy link
Contributor Author

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!;
Copy link
Member

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)

Copy link
Contributor Author

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...

Copy link
Member

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.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thanks!

@JimBobSquarePants JimBobSquarePants merged commit 35e1ae2 into SixLabors:main Mar 20, 2023
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

Successfully merging this pull request may close these issues.

2 participants