-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add to constructor of the BrotliStream
class ability to specify quality
#1556
Comments
Triage: |
I would agree with Carlos on this one. The enum is a better choice, even if it is a little-known fact that Enums can contain arbitrary values e.g. Combined with #42820 such that it is exposed as a configuration property, and combined with the new SmallestSize that gives ordinary users a better idea of what CompressionLevel gives smallest or fastest results, it makes the integer input proposal less of a good argument. That being said, it still feels like CompressionLevel is shoehorning the range of available values. I'm going to propose a set of values in #62658 to remedy that issue. |
Will this API be added in .NET 7? We currently use the workaround where we cast our desired compression level to the CompressionLevel enum. This workaround is no longer possible now that #57561 is merged and none of the default CompressionLevels fit our use case. |
@bartonjs how do you feel about adding a new public BrotliStream(Stream stream, bool leaveOpen, int quality, int window) |
That almost no one will understand what values are valid or what anything means. I'd personally think it was better if it was a static method with some ugly and unapproachable name, since that'll keep it out of the faces of people who just know they were told to "use brotli". |
This overlaps with #42820. We shouldn't do something specific for BrotliStream without also being consistent on Deflate/ZLib/GZipStream. |
While I agree with this, the consequence for us is, we either have to resort to an even uglier hack using Reflection, or we have to find another compression library. It is not too bad for us, because only a single use-case is affected. However this might look different for other developers currently using this workaround. I guess many will only stumble over this after .NET 7 is released. Do you think it would be possible to fast track #42820 so it will be included in .NET 7? Also I tried to run our biggest code base on the latest .NET 7 preview yesterday (triggered by https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/, thanks for the awesome blog post!). I stumbled over another issue with BrotliStream. Decompression throws an exception because of truncation detection. Is it possible that the same change was made as for DeflateStream but only the DeflateStream change was reverted in #72726? I this is the case, the same reasoning applies for BrotliStream and that change should probably be reverted for all compression streams. |
No, we're not adding new APIs to 7 at this point. Just high priority bug fixes. It's almost done. I'd hoped we'd get to it in 7, but too many other priorities took precedence; I would like to see us address it for good in 8 (@jeffhandley).
Can you please open a separate issue for that, with a repro? Thanks. |
It was actually a bug in our side. After properly closing the stream it works now. I guess we just got lucky that it worked in .NET 6. |
Just bumped on this breaking change crashing our code since we pass in |
@buyaa-n @stephentoub is this now being covered with #42820? |
It should be, yes. |
Deduplicating with #42820 |
It would be nice to have the following API:
From the “Introducing Support for Brotli Compression” article and the “Brotli defaults to quality 11” discussion I know how to pass an integer value to the constructor as a compression level, but at the moment it leads to errors. To demonstrate these errors, create a simple console application:
Running it we get the following result:
The results show that first three compression levels were interpreted as the
CompressionLevel
enumeration values:Optimal
Fastest
NoCompression
I. e. first three levels of compression actually work in reverse order. To fix this error I use the following patch:
And I get the following result:
This result looks better, but we don't have the ability to use real level
2
.The text was updated successfully, but these errors were encountered: