diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java index c8f42f114..82c6f80ab 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java @@ -5,7 +5,9 @@ import static software.amazon.polymorph.smithygo.codegen.SymbolUtils.POINTABLE; import static software.amazon.polymorph.smithygo.utils.Constants.DAFNY_RUNTIME_GO_LIBRARY_MODULE; - +import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.stream.Collectors; import software.amazon.polymorph.smithygo.codegen.GenerationContext; import software.amazon.polymorph.smithygo.codegen.GoDelegator; import software.amazon.polymorph.smithygo.codegen.GoWriter; @@ -623,7 +625,8 @@ void generateShim() { } void shimErrors(GoWriter writer) { - for (final var error : model.getShapesWithTrait(ErrorTrait.class)) { + for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) { writer.write( """ case $L.$L: @@ -641,7 +644,8 @@ void shimErrors(GoWriter writer) { } void resourceErrors(GoWriter writer) { - for (final var error : model.getShapesWithTrait(ErrorTrait.class)) { + for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) { writer.write( """ case $L: @@ -710,7 +714,8 @@ void generateUnmodelledErrors(GenerationContext context) { } void generateReferencedResources(final GenerationContext context) { - final var refResources = model.getShapesWithTrait(ReferenceTrait.class); + final var refResources = model.getShapesWithTrait(ReferenceTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { if (!refResource.expectTrait(ReferenceTrait.class).isService()) { final var resource = refResource diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java index 530a08676..d63af7c6b 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java @@ -4,7 +4,9 @@ import static software.amazon.polymorph.smithygo.utils.Constants.DAFNY_RUNTIME_GO_LIBRARY_MODULE; import java.util.Collection; +import java.util.Comparator; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Set; import java.util.stream.Collectors; @@ -205,7 +207,8 @@ public void generateSerializers(final GenerationContext context) { final var refResources = context .model() - .getShapesWithTrait(ReferenceTrait.class); + .getShapesWithTrait(ReferenceTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { final var resource = refResource .expectTrait(ReferenceTrait.class) @@ -584,7 +587,8 @@ public void generateDeserializers(final GenerationContext context) { final var refResources = context .model() - .getShapesWithTrait(ReferenceTrait.class); + .getShapesWithTrait(ReferenceTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { final var resource = refResource .expectTrait(ReferenceTrait.class) @@ -984,7 +988,8 @@ private void generateErrorSerializer(final GenerationContext context) { final var serviceShape = context.settings().getService(context.model()); final var errorShapes = context .model() - .getShapesWithTrait(ErrorTrait.class); + .getShapesWithTrait(ErrorTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); for (final var errorShape : errorShapes) { if ( @@ -1340,7 +1345,8 @@ private void generateErrorDeserializer(final GenerationContext context) { final var serviceShape = context.settings().getService(context.model()); final var errorShapes = context .model() - .getShapesWithTrait(ErrorTrait.class); + .getShapesWithTrait(ErrorTrait.class).stream() + .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); for (final var errorShape : errorShapes) { if ( !errorShape