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

CSHARP-5461: Add targetSerializer parameter to Translate methods. #1596

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rstam
Copy link
Contributor

@rstam rstam commented Jan 16, 2025

No description provided.

Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

Minor comment + there are some failed tests, probably have to check them before completing the PR.

}
var creatorMapArguments = creatorMap?.Arguments?.ToArray();

for (var i = 0; i < constructorParameters.Length; i++)
Copy link
Member

Choose a reason for hiding this comment

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

Should we iterate over creatorMap arguments instead? In such case we do not need to do a member lookup and will use custom member if it was configured explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because the creatorMap could be null.

We only have a creatorMap IFF the serializer is an IBsonClassMapSerializer and not all serializers are.

coll.UpdateOne(filter, updateError, new() { IsUpsert = true });
}

// [Fact]
Copy link
Member

Choose a reason for hiding this comment

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

We probably can either remove this test at all or expect an error here, as we do not support the functionality for now.

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 will remove it before the final commit for this PR.

For now I didn't want to forget about it, but I also didn't want the patch builds to fail.

Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@adelinowona adelinowona left a comment

Choose a reason for hiding this comment

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

Don't we need to also add a targetSerializer parameter for NewHashSetExpressionToAggregationExpressionTranslator and NewListExpressionToAggregationExpressionTranslator?

Comment on lines -35 to +54
itemSerializer ??= itemTranslation.Serializer;
if (itemSerializer == null)
{
itemSerializer = itemTranslation.Serializer;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change is unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right I guess. It's just two ways of writing the same thing.

I don't think I intentionally meant to change it. I think I deleted the line at one point and later realized I needed this to happen and I just wrote it differently.

Which version do you like better? The shorter version or the clearer version?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll prefer the shorter version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants