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

feat(go): handle unhandled orphanShapes #761

Merged
merged 15 commits into from
Jan 17, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes
go 1.23.0

require (
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.1
github.com/dafny-lang/DafnyStandardLibGo v0.0.0
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2
github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library v0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I see TestModels are using Crypto Tools' MPL's StandardLibrary. Did we run this be @robin-aws ? I just want to make sure everyone's aware of the weird dependency graph going around.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is replaced with smithy-dafny module we can check for the name with Robin

replace github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/

)

replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/
replace github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package ExternDefinitions

import (
"fmt"

Wrappers "github.com/dafny-lang/DafnyStandardLibGo/Wrappers"
Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
OrphanedResource "github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes/OrphanedResource"
SimpleOrphanedTypes "github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes/SimpleOrphanedTypes"
simpleorphanedsmithygenerated "github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes/simpleorphanedsmithygenerated"
Expand All @@ -12,12 +10,16 @@ import (

var _ Wrappers.Dummy__

// TODO: Finish implementation.
// This is missing structure converter.
// TODO: Remove this once Dafny bug is fixed.
// Dafny bug: https://t.corp.amazon.com/9a9028fd-2711-4843-b8f0-09965f7e61a7/communication#f03694be-7410-47f9-866d-e43093b018f9
var m_ExternDefinitions = CompanionStruct_Default___{}

func (CompanionStruct_Default___) InitializeOrphanedStructure(input SimpleOrphanedTypes.OrphanedStructure) SimpleOrphanedTypes.OrphanedStructure {
// Missing Structure converter
return input
nativeInput := simpleorphanedsmithygenerated.OrphanedStructure_FromDafny(input)
stringToReplace := "the extern MUST use Smithy-generated conversions to set this value in the native structure"
nativeInput.StringValue = &stringToReplace
dafnyInitializedStructure := simpleorphanedsmithygenerated.OrphanedStructure_ToDafny(nativeInput)
return dafnyInitializedStructure
}

func (CompanionStruct_Default___) CallNativeOrphanedResource(input *OrphanedResource.OrphanedResource) Wrappers.Result {
Expand All @@ -32,7 +34,7 @@ func (CompanionStruct_Default___) CallNativeOrphanedResource(input *OrphanedReso
}

func (CompanionStruct_Default___) CallNativeOrphanedError(input SimpleOrphanedTypes.Error) SimpleOrphanedTypes.Error {
native_error := simpleorphanedsmithygenerated.Error_FromDafny(input)
native_error := simpleorphanedsmithygenerated.Error_FromDafny(input).(simpleorphanedsmithygeneratedtypes.OrphanedError)
native_error.Message = "the extern MUST set this string using the catch-all error converter, NOT the orphaned error-specific converter"
dafny_error_again := simpleorphanedsmithygenerated.Error_ToDafny(native_error)
return dafny_error_again
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ module github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes/test

go 1.23.0

require github.com/dafny-lang/DafnyStandardLibGo v0.0.0

require (
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.1
github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library v0.0.0
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2
github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes v0.0.0
)

replace github.com/smithy-lang/smithy-dafny/TestModels/OrphanedShapes v0.0.0 => ../ImplementationFromDafny-go

replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/
replace github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class GoTestModels extends TestModelTest {
DISABLED_TESTS.add("AggregateReferences");
DISABLED_TESTS.add("Documentation");
DISABLED_TESTS.add("LanguageSpecificLogic");
// Needs work to generate some missing orphaned shape conversion methods
DISABLED_TESTS.add("OrphanedShapes");
DISABLED_TESTS.add("SimpleTypes/BigDecimal");
DISABLED_TESTS.add("SimpleTypes/BigInteger");
DISABLED_TESTS.add("SimpleTypes/SimpleByte");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ protected void generateOrphanedShapesForService(
ShapeType.INTEGER,
ShapeType.UNION,
ShapeType.STRING,
ShapeType.LONG
ShapeType.LONG,
ShapeType.MAP,
ShapeType.LIST,
ShapeType.BOOLEAN,
ShapeType.BLOB
);

for (final var shapeToGenerate : orderedShapes) {
Expand Down
Loading
Loading