Skip to content

Conversation

@Ravi-Raghavan
Copy link
Collaborator

VS-99: Optimize MQL Generator to avoid having 1 using statement for each Bson Type

Comment on lines 25 to 27
#pragma warning disable CS0169 // The field is never used
#pragma warning disable IDE0051
private static readonly BsonTypeCustom123 s_dummyRef1;
private static readonly BsonTimeSpanCustom123 s_dummyRef2;
private static readonly BsonType s_dummyRef1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update the comment please to "// These fields are never used, they are needed to ensure that the relevant usings are not accidently removed"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


var fullTypeName = GetFullName(typeSymbol);
if (s_knownBsonTypes.TryGetValue(fullTypeName, out var knowTypeName))
if (typeSymbol.IsSupportedBsonType() || typeSymbol.IsSupportedBsonSerializationOption())
Copy link
Collaborator

Choose a reason for hiding this comment

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

These methods perform ToDisplayString twice, while we already have fullTypeName.
Lets minimize the lookups and imbed IsSupportedBsonSerializationOption into IsSupportedBsonType (startsWith(NamespaceMongoDBBson)), and receive optional parameter fullTypeName.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@Ravi-Raghavan Ravi-Raghavan requested a review from BorisDog July 13, 2023 20:42
Copy link
Collaborator

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

LGTM (notice the small comment)

private static readonly HashSet<string> s_supportedBsonTypes = new()
{
"MongoDB.Bson.BsonDocument",
"MongoDB.Bson.BsonValue",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Alphabetical order

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@Ravi-Raghavan Ravi-Raghavan merged commit 994bc50 into mongodb:main Jul 14, 2023
@Ravi-Raghavan Ravi-Raghavan deleted the VS-99 branch July 14, 2023 02:14
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.

2 participants