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: no IsSet for AWS SDK types in dotnet #293

Merged
merged 1 commit into from
Oct 2, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import software.amazon.polymorph.traits.LocalServiceTrait;
import software.amazon.polymorph.traits.PositionalTrait;
import software.amazon.polymorph.traits.ReferenceTrait;
import software.amazon.polymorph.utils.AwsSdkNameResolverHelpers;
import software.amazon.polymorph.utils.DafnyNameResolverHelpers;
import software.amazon.polymorph.utils.ModelUtils;
import software.amazon.polymorph.utils.Token;
Expand Down Expand Up @@ -485,15 +486,25 @@ private String generateConstructorArg(final MemberShape memberShape) {
public TokenTree generateExtractOptionalMember(final MemberShape memberShape) {
final String type = nameResolver.baseTypeForShape(memberShape.getId());
final String varName = nameResolver.variableNameForClassProperty(memberShape);
final String isSetMethod = nameResolver.isSetMethodForStructureMember(memberShape);
final String propertyName = nameResolver.classPropertyForStructureMember(memberShape);
return TokenTree.of(
if (AwsSdkNameResolverHelpers.isInAwsSdkNamespace(memberShape.getId())) {
return TokenTree.of(
type,
varName,
"= value.%s != null".formatted(propertyName),
"? value.%s :".formatted(propertyName),
"(%s) null;".formatted(type)
);
} else {
final String isSetMethod = nameResolver.isSetMethodForStructureMember(memberShape);
return TokenTree.of(
type,
varName,
"= value.%s()".formatted(isSetMethod),
"? value.%s :".formatted(propertyName),
"(%s) null;".formatted(type)
);
);
}
}

public TypeConverter generateMemberConverter(final MemberShape memberShape) {
Expand Down
Loading