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

Add C-Style casts support #26

Merged

Conversation

jkurdek
Copy link
Collaborator

@jkurdek jkurdek commented Apr 24, 2024

No description provided.

Copy link
Owner

@simonrozsival simonrozsival left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Thanks for moving the models to a separate file.


if (foundCast && part is MemberAccess memberAccess)
{
array[i] = new ConditionalAccess(memberAccess);
Copy link
Owner

Choose a reason for hiding this comment

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

Is it correct to keep the foundCast set to true? Shouldn't we "reset" it after the first member access"? Also when there is a ConditionalAccess, shouldn't that reset the flag too?

Comment on lines 62 to 64
new ConditionalAccess(new MemberAccess("X")),
new ConditionalAccess(new MemberAccess("Y")),
new ConditionalAccess(new MemberAccess("Z")),
Copy link
Owner

Choose a reason for hiding this comment

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

I think the correct transformation would be turning just the first MemberAccess into a conditional one. Or am I missing something?

return TransformExplicitCastsToAsCasts(source);
}

private static CodeWriterBinding TransformExplicitCastsToAsCasts(CodeWriterBinding source) {
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure if we want to move this code to a separate class. I see value in being able to test this separately, but it seems too complicated for this use case. If we were planning on adding more transforms, it might be great way to do this, but I don't think we'll add more. I would personally implement a similar loop in AppendHandlersArray to correctly insert ? and test this using integration tests. What do you think?

@simonrozsival simonrozsival merged commit a573668 into simonrozsival:binding-source-generator Apr 30, 2024
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants