diff --git a/.autover/changes/dd27e0cc-00fb-4dc0-b9c4-92b2ddea42c2.json b/.autover/changes/dd27e0cc-00fb-4dc0-b9c4-92b2ddea42c2.json new file mode 100644 index 0000000..da2de81 --- /dev/null +++ b/.autover/changes/dd27e0cc-00fb-4dc0-b9c4-92b2ddea42c2.json @@ -0,0 +1,13 @@ +{ + "Projects": [ + { + "Name": "AWS.AspNetCore.DistributedCacheProvider", + "Type": "Major", + "ChangelogMessages": [ + "Updated the .NET SDK dependencies to the latest version 4.0.0-preview.4", + "Marked project as trimmable", + "Added SourceLink support" + ] + } + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4709263..5f83c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,19 @@ -# Changelog +## Release 2024-04-20 -## 0.9.3 (2024-04-20) +### AWS.AspNetCore.DistributedCacheProvider (0.9.3) - Update User-Agent string -## 0.9.2 (2023-07-28) +## Release 2023-07-28 + +### AWS.AspNetCore.DistributedCacheProvider (0.9.2) - Add PackageReadmeFile attribute to show README file in NuGet -## 0.9.1 (2023-07-28) +## Release 2023-07-28 + +### AWS.AspNetCore.DistributedCacheProvider (0.9.1) - Added the repository README file to the NuGet package -## 0.9.0 (2023-07-06) +## Release 2023-07-06 + +### AWS.AspNetCore.DistributedCacheProvider (0.9.0) - Initial preview release \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4b6a1c..880cb86 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,42 @@ To send us a pull request, please: GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). +## Adding a `change file` to your contribution branch +Each contribution branch should include a `change file` that contains a changelog message for each project that has been updated, as well as the type of increment to perform for those changes when versioning the project. +A `change file` looks like the following example: +```json +{ + "Projects": [ + { + "Name": "AWS.AspNetCore.DistributedCacheProvider", + "Type": "Patch", + "ChangelogMessages": [ + "Fixed an issue causing a failure somewhere" + ] + } + ] +} +``` +The `change file` lists all the modified projects, the changelog message for each project as well as the increment type. +These files are located in the repo at .autover/changes/ +You can use the `AutoVer` tool to create the change file. You can install it using the following command: +``` +dotnet tool install -g AutoVer +``` +You can create the `change file` using the following command: +``` +autover change --project-name "AWS.AspNetCore.DistributedCacheProvider" -m "Fixed an issue causing a failure somewhere +``` +Note: Make sure to run the command from the root of the repository. +You can update the command to specify which project you are updating. +The available projects are: +* AWS.AspNetCore.DistributedCacheProvider +The possible increment types are: +* Patch +* Minor +* Major +Note: You do not need to create a new `change file` for every changelog message or project within your branch. You can create one `change file` that contains all the modified projects and the changelog messages. + ## Finding contributions to work on Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. diff --git a/SampleApp/SampleApp.csproj b/SampleApp/SampleApp.csproj index 9c21158..893fabb 100644 --- a/SampleApp/SampleApp.csproj +++ b/SampleApp/SampleApp.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/buildtools/ci.buildspec.yml b/buildtools/ci.buildspec.yml index 125fdc9..362cff6 100644 --- a/buildtools/ci.buildspec.yml +++ b/buildtools/ci.buildspec.yml @@ -3,7 +3,7 @@ version: 0.2 phases: install: runtime-versions: - dotnet: 6.x + dotnet: 8.x build: commands: - dotnet test --verbosity normal AWS.DistributedCacheProvider.sln --configuration Release --logger trx --results-directory ./testresults diff --git a/src/AWS.DistributedCacheProvider/AWS.DistributedCacheProvider.csproj b/src/AWS.DistributedCacheProvider/AWS.DistributedCacheProvider.csproj index 266c4af..b47b712 100644 --- a/src/AWS.DistributedCacheProvider/AWS.DistributedCacheProvider.csproj +++ b/src/AWS.DistributedCacheProvider/AWS.DistributedCacheProvider.csproj @@ -1,11 +1,11 @@ - net6.0 + net6.0;net8.0 AWS.DistributedCacheProvider enable enable - 0.9.3 + 2.0.0-preview.1 AWS.AspNetCore.DistributedCacheProvider AWS Provider for ASP.NET Core's IDistributedCache The AWS Distributed Cache provider provides an IDistributedCache implementation backed by DynamoDB. @@ -20,7 +20,16 @@ true ..\..\public.snk - README.md + README.md + + true + true + true + snupkg + + + + true @@ -35,8 +44,9 @@ - - + + + diff --git a/src/AWS.DistributedCacheProvider/DynamoDBDistributedCache.cs b/src/AWS.DistributedCacheProvider/DynamoDBDistributedCache.cs index 8401c92..4a09c0f 100644 --- a/src/AWS.DistributedCacheProvider/DynamoDBDistributedCache.cs +++ b/src/AWS.DistributedCacheProvider/DynamoDBDistributedCache.cs @@ -392,8 +392,6 @@ private DateTimeOffset UnixSecondsToDateTimeOffset(string seconds) return DateTimeOffset.FromUnixTimeSeconds((long)double.Parse(seconds)); } - - /// /// Retrieves the value associated with in the cache and updates the Item's TTL. /// If there is no value associated with the or there is a value, but the Item's TTL @@ -429,6 +427,12 @@ private DateTimeOffset UnixSecondsToDateTimeOffset(string seconds) throw new DynamoDBDistributedCacheException($"Failed to get Item with key {key}. Caused by {e.Message}", e); } + if (getItemResponse.Item is null) + { + _logger.LogDebug("DynamoDB did not find an Item associated with the key {key}", key); + return null; + } + //Check if there is a value we should be returning to the client. If there is no value, there is no reason to refresh the Item if (getItemResponse.Item.ContainsKey(VALUE_KEY)) { diff --git a/src/AWS.DistributedCacheProvider/Internal/DynamoDBCacheProviderHelper.cs b/src/AWS.DistributedCacheProvider/Internal/DynamoDBCacheProviderHelper.cs index eaad23e..ea023f5 100644 --- a/src/AWS.DistributedCacheProvider/Internal/DynamoDBCacheProviderHelper.cs +++ b/src/AWS.DistributedCacheProvider/Internal/DynamoDBCacheProviderHelper.cs @@ -64,7 +64,7 @@ public static AttributeValue CalculateTTL(DistributedCacheEntryOptions options) var ttl = DateTimeOffset.UtcNow.Add(((TimeSpan)options.SlidingExpiration)); //Cannot be later than the deadline var absoluteTTL = CalculateTTLDeadline(options); - if (absoluteTTL.NULL) + if (absoluteTTL.NULL is not null && (bool)absoluteTTL.NULL) { return new AttributeValue { N = ttl.ToUnixTimeSeconds().ToString() }; } diff --git a/src/AWS.DistributedCacheProvider/Internal/DynamoDBTableCreator.cs b/src/AWS.DistributedCacheProvider/Internal/DynamoDBTableCreator.cs index c598e76..e900ef6 100644 --- a/src/AWS.DistributedCacheProvider/Internal/DynamoDBTableCreator.cs +++ b/src/AWS.DistributedCacheProvider/Internal/DynamoDBTableCreator.cs @@ -72,7 +72,8 @@ public async Task CreateTableIfNotExistsAsync(IAmazonDynamoDB client, st private string ValidateTable(TableDescription description) { var partitionKeyName = ""; - foreach (var key in description.KeySchema) + var keySchema = description.KeySchema ?? new List(); + foreach (var key in keySchema) { if (key.KeyType.Equals(KeyType.RANGE)) { @@ -81,7 +82,8 @@ private string ValidateTable(TableDescription description) } else //We know the key is of type Hash { - foreach (var attributeDef in description.AttributeDefinitions) + var attributeDefinitions = description.AttributeDefinitions ?? new List(); + foreach (var attributeDef in attributeDefinitions) { if (attributeDef.AttributeName.Equals(key.AttributeName) && attributeDef.AttributeType != ScalarAttributeType.S) { diff --git a/test/AWS.DistributedCacheProviderIntegrationTests/AWS.DistributedCacheProviderIntegrationTests.csproj b/test/AWS.DistributedCacheProviderIntegrationTests/AWS.DistributedCacheProviderIntegrationTests.csproj index c1d34c4..d256798 100644 --- a/test/AWS.DistributedCacheProviderIntegrationTests/AWS.DistributedCacheProviderIntegrationTests.csproj +++ b/test/AWS.DistributedCacheProviderIntegrationTests/AWS.DistributedCacheProviderIntegrationTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -9,8 +9,8 @@ - - + + diff --git a/test/AWS.DistributedCacheProviderUnitTests/AWS.DistributedCacheProviderUnitTests.csproj b/test/AWS.DistributedCacheProviderUnitTests/AWS.DistributedCacheProviderUnitTests.csproj index d9fdd14..39a71d9 100644 --- a/test/AWS.DistributedCacheProviderUnitTests/AWS.DistributedCacheProviderUnitTests.csproj +++ b/test/AWS.DistributedCacheProviderUnitTests/AWS.DistributedCacheProviderUnitTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/test/AWS.DistributedCacheProviderUnitTests/DynamoDBDistributedCacheHelperTests.cs b/test/AWS.DistributedCacheProviderUnitTests/DynamoDBDistributedCacheHelperTests.cs index 5f630d2..93c7268 100644 --- a/test/AWS.DistributedCacheProviderUnitTests/DynamoDBDistributedCacheHelperTests.cs +++ b/test/AWS.DistributedCacheProviderUnitTests/DynamoDBDistributedCacheHelperTests.cs @@ -38,8 +38,8 @@ public void CalculateTTL_NoSlidingWindow_ReturnDeadline() }; var deadline = DynamoDBCacheProviderHelper.CalculateTTLDeadline(options); var ttl = DynamoDBCacheProviderHelper.CalculateTTL(options); - Assert.False(deadline.NULL); - Assert.False(ttl.NULL); + Assert.Null(deadline.NULL); + Assert.Null(ttl.NULL); Assert.Equal(ttl.N, deadline.N); }