Skip to content

Commit db78168

Browse files
authored
feat: upgrade to .NET 10 (#80)
* refactor: updated project to .NET 10 and updated dependencies * chore(logs): remove build and test log files to clean up repository * chore(deps): update NuGet packages to latest versions across all projects Update outdated AWS SDK and Lambda packages for .NET 10 compatibility: - Amazon.Lambda.Core 2.8.0 → 2.8.1 - AWSSDK.DynamoDBv2 4.0.10.8 → 4.0.14 - AWSSDK.XRay 4.0.3.11 → 4.0.3.13 - AWSSDK.EventBridge 4.0.5.13 → 4.0.5.15 - AWSSDK.StepFunctions 4.0.2.7 → 4.0.2.9 Also removes Microsoft.NET.Test.Sdk from Common.csproj as it is a shared library, not a test project. * ci: fix GitHub Actions for .NET 10 and release-drafter - Add setup-dotnet step to codeql-analysis.yml for .NET 10.0.x - Split release-drafter.yml into config (.github/) and workflow (.github/workflows/) - Fix 'label' typo to 'labels' in Maintenance category config * fix(contracts,web): Add JsonPropertyName attributes for snake_case API Gateway payloads API Gateway sends snake_case JSON (property_id, seller_name) but C# models used PascalCase properties, causing null deserialization. Added [JsonPropertyName] attributes to CreateContractRequest, UpdateContractRequest, and ApprovePublicationRequest. Added tests verifying snake_case JSON deserialization.
1 parent f5d715d commit db78168

21 files changed

Lines changed: 172 additions & 48 deletions

File tree

.github/release-drafter.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
name: Release Drafter
2-
3-
on:
4-
push:
5-
# branches to consider in the event; optional, defaults to all
6-
branches:
7-
- main
8-
9-
permissions:
10-
contents: read
11-
121
categories:
13-
142
- title: '🚀 Enhancements'
153
labels:
164
- feature
@@ -24,7 +12,7 @@ categories:
2412
- bugfix
2513
- bug
2614
- title: '🧰 Maintenance'
27-
label:
15+
labels:
2816
- chore
2917

3018
template: |
@@ -42,18 +30,3 @@ template: |
4230
4331
exclude-labels:
4432
- skip-changelog
45-
46-
jobs:
47-
update_release_draft:
48-
permissions:
49-
# write permission is required to create a github release
50-
contents: write
51-
# write permission is required for autolabeler
52-
# otherwise, read permission is required at least
53-
pull-requests: write
54-
runs-on: ubuntu-latest
55-
steps:
56-
# Drafts your next Release notes as Pull Requests are merged into "master"
57-
- uses: release-drafter/release-drafter@v6
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v4
23-
- name: Setup .NET 8.0
23+
- name: Setup .NET 10.0
2424
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a
2525
with:
26-
dotnet-version: 8.0.x
26+
dotnet-version: 10.0.x
2727
- name: Install solution dependencies
2828
run: dotnet restore
2929
- name: Build

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929

30+
- name: Setup .NET 10.0
31+
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a
32+
with:
33+
dotnet-version: 10.0.x
34+
3035
# Initializes the CodeQL tools for scanning.
3136
- name: Initialize CodeQL
3237
uses: github/codeql-action/init@v3
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
update_release_draft:
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: release-drafter/release-drafter@v6
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Unicorn.Approvals/ApprovalsService.Tests/ApprovalsService.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<AssemblyName>Unicorn.Approvals.ApprovalsService.Tests</AssemblyName>
55
<RootNamespace>Unicorn.Approvals.ApprovalsService.Tests</RootNamespace>
66
</PropertyGroup>

Unicorn.Approvals/ApprovalsService/ApprovalsService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

Unicorn.Approvals/Infrastructure/approvals-service/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Conditions:
4848

4949
Globals:
5050
Function:
51-
Runtime: dotnet8
51+
Runtime: dotnet10
5252
MemorySize: 512
5353
Timeout: 10
5454
Tracing: Active

Unicorn.Contracts/ContractsService.Test/ContractEventHandlerTest.cs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task Create_contract_saves_message_with_new_status()
5757
var mockDynamoDbClient = Substitute.ForPartsOf<AmazonDynamoDBClient>();
5858
mockDynamoDbClient.PutItemAsync(Arg.Any<PutItemRequest>())
5959
.Returns(new PutItemResponse());
60-
60+
6161
var context = TestHelpers.NewLambdaContext();
6262

6363
// Act
@@ -66,7 +66,65 @@ public async Task Create_contract_saves_message_with_new_status()
6666

6767
// Assert
6868
await mockDynamoDbClient.Received(1).PutItemAsync(Arg.Any<PutItemRequest>());
69-
69+
70+
}
71+
72+
[Fact]
73+
public async Task Create_contract_with_snake_case_json_populates_all_dynamodb_attributes()
74+
{
75+
// Arrange - use snake_case JSON matching the actual API Gateway payload format
76+
var snakeCaseJson = """
77+
{
78+
"address": {
79+
"country": "USA",
80+
"city": "Anytown",
81+
"street": "Main Street",
82+
"number": 222
83+
},
84+
"seller_name": "John Doe",
85+
"property_id": "usa/anytown/main-street/222"
86+
}
87+
""";
88+
89+
var sqsEvent = new SQSEvent()
90+
{
91+
Records = new List<SQSEvent.SQSMessage>
92+
{
93+
new()
94+
{
95+
Body = snakeCaseJson,
96+
MessageAttributes = new Dictionary<string, SQSEvent.MessageAttribute>
97+
{
98+
{ "HttpMethod", new SQSEvent.MessageAttribute { StringValue = "POST" } }
99+
}
100+
}
101+
}
102+
};
103+
104+
PutItemRequest? capturedRequest = null;
105+
var mockDynamoDbClient = Substitute.ForPartsOf<AmazonDynamoDBClient>();
106+
mockDynamoDbClient.PutItemAsync(Arg.Do<PutItemRequest>(r => capturedRequest = r))
107+
.Returns(new PutItemResponse());
108+
109+
var context = TestHelpers.NewLambdaContext();
110+
111+
// Act
112+
var function = new ContractEventHandler(mockDynamoDbClient);
113+
await function.FunctionHandler(sqsEvent, context);
114+
115+
// Assert - verify DynamoDB item has non-empty attribute values
116+
Assert.NotNull(capturedRequest);
117+
Assert.False(string.IsNullOrEmpty(capturedRequest.Item["PropertyId"].S),
118+
"PropertyId should not be null or empty - snake_case 'property_id' must map to PascalCase 'PropertyId'");
119+
Assert.False(string.IsNullOrEmpty(capturedRequest.Item["SellerName"].S),
120+
"SellerName should not be null or empty - snake_case 'seller_name' must map to PascalCase 'SellerName'");
121+
Assert.NotNull(capturedRequest.Item["Address"].M);
122+
Assert.False(string.IsNullOrEmpty(capturedRequest.Item["Address"].M["City"].S),
123+
"Address.City should not be null or empty");
124+
Assert.False(string.IsNullOrEmpty(capturedRequest.Item["Address"].M["Street"].S),
125+
"Address.Street should not be null or empty");
126+
Assert.Equal("usa/anytown/main-street/222", capturedRequest.Item["PropertyId"].S);
127+
Assert.Equal("John Doe", capturedRequest.Item["SellerName"].S);
70128
}
71129

72130
[Fact]

Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<AssemblyName>Unicorn.Contracts.ContractService.Tests</AssemblyName>
66
<RootNamespace>Unicorn.Contracts.ContractService.Tests</RootNamespace>
77
<Nullable>enable</Nullable>

Unicorn.Contracts/ContractsService/Contract.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Text.Json.Serialization;
67
using Amazon.DynamoDBv2.Model;
78

89
namespace Unicorn.Contracts.ContractService;
@@ -61,8 +62,10 @@ public Dictionary<string, AttributeValue> ToMap()
6162
/// </summary>
6263
public class CreateContractRequest
6364
{
64-
public string? PropertyId { get; set; }
65+
[JsonPropertyName("property_id")]
66+
public string? PropertyId { get; set; }
6567
public Address? Address { get; set; }
68+
[JsonPropertyName("seller_name")]
6669
public string? SellerName { get; set; }
6770
}
6871

@@ -71,5 +74,6 @@ public class CreateContractRequest
7174
/// </summary>
7275
public class UpdateContractRequest
7376
{
77+
[JsonPropertyName("property_id")]
7478
public string? PropertyId { get; set; }
7579
}

0 commit comments

Comments
 (0)