C# extractor: Limit trap strings to 1MB#924
Merged
hvitved merged 4 commits intogithub:rc/1.19from Feb 13, 2019
Merged
Conversation
…ated by the fact that we need to limit the number of bytes to output, rather than the number of characters.
hvitved
requested changes
Feb 12, 2019
Contributor
hvitved
left a comment
There was a problem hiding this comment.
Very nice! Just a couple of remarks.
| { | ||
| if (column > 0) tb.Append(", "); | ||
| if (a is Label) | ||
| if (a is Label l) |
Contributor
There was a problem hiding this comment.
Now that you are at it, how about changing this sequence of ifs to a switch with pattern matching?
Contributor
Author
There was a problem hiding this comment.
Sounds like a good idea for a query.
| // Optimization: only count the actual number of bytes if there is the possibility | ||
| // of the strings exceeding maxStringBytes | ||
| return encoding.GetMaxByteCount(array.Sum(s => s.Length)) > maxStringBytes && | ||
| array.Sum(s => encoding.GetByteCount(s)) > maxStringBytes; |
Contributor
There was a problem hiding this comment.
array.Sum(encoding.GetByteCount)
Contributor
Author
There was a problem hiding this comment.
Sounds like a good idea for a query.
Contributor
|
This pull request introduces 1 alert when merging e18eeb8 into 97fc4b0 - view on LGTM.com new alerts:
Comment posted by LGTM.com |
hvitved
approved these changes
Feb 12, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is made more complicated by the fact that we need to limit the size of the encoded output to 1MB, so we can't just truncate each string to 1M characters.
There are 2 test cases: