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

Address some more analyzer warnings #47

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

stephentoub
Copy link
Contributor

No description provided.

@@ -35,10 +35,10 @@ OpenAIErrorResponse errorResponse
public string ToExceptionMessage(int httpStatus)
{
StringBuilder messageBuilder = new();
messageBuilder.AppendLine($"HTTP {httpStatus} ({Type}: {Code})");
messageBuilder.Append("HTTP ").Append(httpStatus).Append(" (").Append(Type).Append(": ").Append(Code).AppendLine(")");
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the reason for this change?

Copy link
Contributor Author

@stephentoub stephentoub Jun 11, 2024

Choose a reason for hiding this comment

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

On netstandard2.0 it's allocating a new string only to then append that string.

On .NET Core it'll use the more efficient overload to avoid that, but an analyzer points out it should ideally be passing in a culture, and I can't do that without an ifdef.

If you're ok with an ifdef, I could do that and accept the lesser perf on netstandard (after all, this appears to only be exceptional). Or I could undo and if/when we enable that analyzer permanently we could suppress it here.

@trrwilson trrwilson merged commit 22ab606 into openai:main Jun 14, 2024
1 check passed
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.

None yet

3 participants