Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
vNext (Month Day, Year)
-----------------------

**New this week**

- (When complete) Add profile file provider for region (#594, #xyz)
- Add experimental `dvr` module to smithy-client. This will enable easier testing of HTTP traffic. (#640)
- Add profile file credential provider implementation. This implementation currently does not support credential sources
for assume role providers other than environment variables. (#640)
- :bug: Fix name collision that occurred when a model had both a union and a structure named `Result` (#643)

v0.20 (August 10th, 2021)
--------------------------
Expand Down
8 changes: 7 additions & 1 deletion codegen-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ val CodegenTests = listOf(
),
CodegenTest(
"crate#Config",
"naming_test", """
"naming_test_ops", """
, "codegen": { "renameErrors": false }
""".trimIndent()
),
CodegenTest(
"naming_obs_structs#NamingObstacleCourseStructs",
"naming_test_structs", """
, "codegen": { "renameErrors": false }
""".trimIndent()
)
Expand Down
53 changes: 53 additions & 0 deletions codegen-test/model/naming-obstacle-course-structs.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$version: "1.0"
namespace naming_obs_structs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to put this test into the existing naming-obstacle-course.smithy, but that one already defines operation Result, which would conflict unless it was in a different namespace.

I'm open to ideas here since I dislike the names here (ops vs structs) as they don't really make that much sense. Can we have a larger multi-namespace, multi-file, naming-obstacle-course service that still checks things such as the namespace being crate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

not really, one service is one namespace. We could use renames but that would of course, defeat the purpose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you can have nested namespaces in Smithy, so there's a chance this might work. No idea how our codegen handles it though.


use aws.protocols#awsJson1_1
use aws.api#service

/// Confounds model generation machinery with lots of problematic names
@awsJson1_1
@service(sdkId: "NamingObstacleCourseStructs")
service NamingObstacleCourseStructs {
version: "2006-03-01",
operations: [
Structs,
]
}

structure SomethingElse {
result: Result,
resultList: ResultList,
option: Option,
optionList: OptionList,
someUnion: SomeUnion,
}

union SomeUnion {
Result: Result,
Option: Option,
}

structure Result {
value: String,
}
list ResultList {
member: Result,
}
structure Option {
value: String,
}
list OptionList {
member: Result,
}

structure StructsInputOutput {
result: Result,
resultList: ResultList,
option: Option,
optionList: OptionList,
somethingElse: SomethingElse,
}
operation Structs {
input: StructsInputOutput,
output: StructsInputOutput
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UnionGenerator(
if (sortedMembers.size == 1) {
Attribute.Custom("allow(irrefutable_let_patterns)").render(this)
}
rustBlock("pub fn as_$funcNamePart(&self) -> Result<&#T, &Self>", memberSymbol) {
rustBlock("pub fn as_$funcNamePart(&self) -> std::result::Result<&#T, &Self>", memberSymbol) {
rust("if let ${unionSymbol.name}::$variantName(val) = &self { Ok(&val) } else { Err(&self) }")
}
rustBlock("pub fn is_$funcNamePart(&self) -> bool") {
Expand Down