Skip to content

Commit 118804b

Browse files
alex-chewrobin-aws
andauthored
feat: extract CodegenEngine (#212)
Co-authored-by: Robin Salkeld <[email protected]>
1 parent 955244d commit 118804b

File tree

36 files changed

+5383
-422
lines changed

36 files changed

+5383
-422
lines changed

.github/workflows/smithy-polymorph.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ jobs:
2828
arguments: :smithy-dafny-codegen:test
2929
build-root-directory: codegen
3030

31+
# Required for building the SQS model
32+
- name: Locally cache smithy-dafny-codegen
33+
uses: gradle/gradle-build-action@v2
34+
with:
35+
arguments: :smithy-dafny-codegen:publishToMavenLocal
36+
build-root-directory: codegen
37+
38+
- name: Sanity-check SQS test model via plugin
39+
uses: gradle/gradle-build-action@v2
40+
with:
41+
arguments: build --info
42+
build-root-directory: TestModels/aws-sdks/sqs
43+
3144
- name: Execute codegen build
3245
uses: gradle/gradle-build-action@v2
3346
with:

.github/workflows/test_models_dafny_verification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
TestModels/Union,
4141
TestModels/aws-sdks/ddb,
4242
TestModels/aws-sdks/kms,
43-
TestModels/aws-sdks/sqs,
43+
TestModels/aws-sdks/sqs-via-cli,
4444
]
4545
os: [ ubuntu-latest ]
4646
runs-on: ${{ matrix.os }}

.github/workflows/test_models_net_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
TestModels/Union,
4141
TestModels/aws-sdks/ddb,
4242
TestModels/aws-sdks/kms,
43-
TestModels/aws-sdks/sqs,
43+
TestModels/aws-sdks/sqs-via-cli,
4444
]
4545
dotnet-version: [ '6.0.x' ]
4646
os: [ ubuntu-latest ]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# AWS-SDK-SQS
2+
3+
This project builds a Dafny SDK for [AWS SQS](https://aws.amazon.com/sqs/).
4+
It is a copy of the `TestModels/aws-sdks/sqs` project,
5+
but it generates code using the older CLI instead of the newer Smithy build plugin.
6+
This project will eventually be removed entirely as the CLI is deprecated.
7+
For more details, please see `TestModels/aws-sdks/sqs/README.md`.
8+
9+
## Build
10+
11+
### .NET
12+
13+
1. Generate the Wrappers using `polymorph`
14+
```
15+
make polymorph_dafny polymorph_net
16+
```
17+
18+
2. Transpile the tests (and implementation) to the target runtime.
19+
```
20+
make transpile_net
21+
```
22+
23+
3. Generate the executable in the .NET and execute the tests
24+
```
25+
make test_net
26+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Amazon;
2+
using Amazon.SQS;
3+
using Wrappers_Compile;
4+
using Amazon.Runtime;
5+
using Com.Amazonaws.Sqs;
6+
7+
// This extern is identified in Dafny code
8+
// that refines the AWS SDK SQS Model
9+
namespace Dafny.Com.Amazonaws.Sqs
10+
{
11+
public partial class __default
12+
{
13+
14+
public static
15+
_IResult<
16+
Types.ISQSClient,
17+
Types._IError
18+
>
19+
SQSClient()
20+
{
21+
var client = new AmazonSQSClient();
22+
23+
return Result<
24+
Types.ISQSClient,
25+
Types._IError
26+
>
27+
.create_Success(new SQSShim(client));
28+
}
29+
}
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<ImplicitUsings>disable</ImplicitUsings>
5+
<Nullable>disable</Nullable>
6+
<TargetFrameworks>net6.0</TargetFrameworks>
7+
<LangVersion>10</LangVersion>
8+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="DafnyRuntime" Version="3.10.0.41215" />
13+
<PackageReference Include="AWSSDK.Core" Version="3.7.100" />
14+
<PackageReference Include="AWSSDK.SQS" Version="3.7.100" />
15+
<!--
16+
System.Collections.Immutable can be removed once dafny.msbuild is updated with
17+
https://github.com/dafny-lang/dafny.msbuild/pull/10 and versioned
18+
-->
19+
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
20+
<!-- Work around for dafny-lang/dafny/issues/1951; remove once resolved -->
21+
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
22+
23+
<Compile Include="Extern/**/*.cs" />
24+
<Compile Include="Generated/**/*.cs" />
25+
<Compile Include="ImplementationFromDafny.cs" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<ProjectReference Include="../../../../dafny-dependencies/StandardLibrary/runtimes/net/STD.csproj" />
30+
</ItemGroup>
31+
32+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<RootNamespace>TestSQS</RootNamespace>
5+
<ImplicitUsings>disable</ImplicitUsings>
6+
<Nullable>disable</Nullable>
7+
<TargetFrameworks>net6.0</TargetFrameworks>
8+
<LangVersion>10</LangVersion>
9+
<OutputType>Exe</OutputType>
10+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<!--
15+
System.Collections.Immutable can be removed once dafny.msbuild is updated with
16+
https://github.com/dafny-lang/dafny.msbuild/pull/10 and versioned
17+
-->
18+
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
19+
<!-- Work around for dafny-lang/dafny/issues/1951; remove once resolved -->
20+
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
21+
22+
<ProjectReference Include="../SQS.csproj" />
23+
<Compile Include="TestsFromDafny.cs" />
24+
</ItemGroup>
25+
26+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
include "../Model/ComAmazonawsSqsTypes.dfy"
5+
6+
module {:extern "Dafny.Com.Amazonaws.Sqs"} Com.Amazonaws.Sqs refines AbstractComAmazonawsSqsService {
7+
8+
function method DefaultSQSClientConfigType() : SQSClientConfigType {
9+
SQSClientConfigType
10+
}
11+
12+
}

0 commit comments

Comments
 (0)