-
Notifications
You must be signed in to change notification settings - Fork 28
chore: improve .NET mock server #632
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
base: main
Are you sure you want to change the base?
Conversation
Add some improvements to the .NET mock server. These features are used by the ADO.NET driver tests.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several enhancements to the .NET mock server, such as configurable database dialects, waiting for specific requests, and handling larger messages. While these are valuable additions for testing, I've found a couple of high-severity issues related to performance and thread-safety in the new helper methods. I've also noted a minor issue with a magic number. My review includes specific code suggestions to address these points, aiming to improve the robustness and efficiency of the mock server.
spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-mockserver/MockSpannerServer.cs
Show resolved
Hide resolved
spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-mockserver/MockSpannerServer.cs
Show resolved
Hide resolved
| { | ||
| // Setup a HTTP/2 endpoint without TLS. | ||
| options.Listen(endpoint, o => o.Protocols = HttpProtocols.Http2); | ||
| options.Limits.MaxRequestBodySize = 100_000_000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value 100_000_000 is used here as a magic number. To improve readability and maintainability, it's recommended to extract it into a named constant. You could define a private constant at the class level:
private const int MaxRequestBodySize = 100_000_000;And then use it here:
options.Limits.MaxRequestBodySize = MaxRequestBodySize;This makes the code more self-documenting and easier to manage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
5b67fb5 to
031e53f
Compare
Add some improvements to the .NET mock server. These features are used by the ADO.NET driver tests.