-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Optionally generate (mostly) complete projects (#390)
*Description of changes:* Adds a new `--generate` option that accepts a "generation aspect" argument, and can be specified multiple times. The available aspects are: * `project-files` - files like `build.gradle.kts` or `Service.csproj` * `client-constructors` - externally defined [wrapped] client constructors, and similar top-level Dafny module boilerplate (open to a better name for this one) * `impl-stubs` - stubbed out Dafny concrete operations modules and tests. These options make it much quicker to create new libraries, especially new TestModels. The last option is intended to be used once to get started on files that do have to be manually edited, but the other two can be left on more permanently. I set up a templated file mechanism for all these kinds of assets, since they are mostly static content with just a few pieces that depend on the service name/sdkID and other parameters. It uses [the shared `AbstractCodeWriter` templating mechanism](https://smithy.io/2.0/guides/building-codegen/generating-code.html) from the core Smithy implementation. Also used this to generate the missing files to make `Timestamp` work for .NET (it doesn't work yet for Java because of some apparent confusion over `Date` vs. `Instant`)
- Loading branch information
Showing
32 changed files
with
960 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Codegen templates (often not parsable) | ||
codegen/smithy-dafny-codegen/src/main/resources/templates/**/*.* | ||
|
||
# Build folders (faster to ignore tons of irrelevant files) | ||
**/runtimes/rust/target/debug/**/*.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
TestModels/SimpleTypes/SimpleTimestamp/src/SimpleTimestampImpl.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. | ||
include "../Model/SimpleTypesTimestampTypes.dfy" | ||
module SimpleTypesTimestampImpl refines AbstractSimpleTypesTimestampOperations { | ||
datatype Config = Config | ||
type InternalConfig = Config | ||
predicate ValidInternalConfig?(config: InternalConfig) | ||
{true} | ||
function ModifiesInternalConfig(config: InternalConfig): set<object> | ||
{{}} | ||
predicate GetTimestampEnsuresPublicly(input: GetTimestampInput , output: Result<GetTimestampOutput, Error>) | ||
{true} | ||
|
||
|
||
|
||
method GetTimestamp ( config: InternalConfig , input: GetTimestampInput ) | ||
returns (output: Result<GetTimestampOutput, Error>) | ||
|
||
{ | ||
var res := GetTimestampOutput(value := input.value); | ||
return Success(res); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
TestModels/SimpleTypes/SimpleTimestamp/test/SimpleTimestampImplTest.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
include "../src/Index.dfy" | ||
|
||
module SimpleTimestampImplTest { | ||
|
||
import SimpleTimestamp | ||
import opened SimpleTypesTimestampTypes | ||
import opened Wrappers | ||
|
||
method {:test} TestClient(){ | ||
var client :- expect SimpleTimestamp.SimpleTimestamp(); | ||
|
||
TestGetTimestamp(client); | ||
} | ||
|
||
method TestGetTimestamp(client: ISimpleTypesTimestampClient) | ||
requires client.ValidState() | ||
modifies client.Modifies | ||
ensures client.ValidState() | ||
{ | ||
var dafnyTimestamp := "2024-06-11T12:34:56"; | ||
var ret :- expect client.GetTimestamp(SimpleTimestamp.Types.GetTimestampInput(value:= Some(dafnyTimestamp))); | ||
expect ret.value == Some(dafnyTimestamp); | ||
print ret; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
TestModels/SimpleTypes/SimpleTimestamp/test/WrappedSimpleTimestampTest.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
include "../src/WrappedSimpleTypesTimestampImpl.dfy" | ||
include "SimpleTimestampImplTest.dfy" | ||
|
||
module WrappedSimpleTypesTimestampTest { | ||
import WrappedSimpleTypesTimestampService | ||
import SimpleTimestampImplTest | ||
import opened Wrappers | ||
method{:test} GetString() { | ||
var client :- expect WrappedSimpleTypesTimestampService.WrappedSimpleTimestamp(); | ||
|
||
SimpleTimestampImplTest.TestGetTimestamp(client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
TestModels/aws-sdks/lakeformation/runtimes/net/Extern/LakeFormationClient.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.