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

Fix ref files from System.IO.Compression and System.IO.Compression.Brotli with autogenerated file using GenAPI #112440

Merged
merged 9 commits into from
Feb 12, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

namespace System.IO.Compression
{
public sealed class BrotliCompressionOptions
public sealed partial class BrotliCompressionOptions
{
public int Quality { get; set; }
public BrotliCompressionOptions() { }
public int Quality { get { throw null; } set { } }
}
public partial struct BrotliDecoder : System.IDisposable
{
Expand Down
22 changes: 17 additions & 5 deletions src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void SetLength(long value) { }
public override void Write(byte[] buffer, int offset, int count) { }
public override void Write(System.ReadOnlySpan<byte> buffer) { }
public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask WriteAsync(System.ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask WriteAsync(System.ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

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

This will be a source-breaking change. Can we double check which is intended here?

Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure this is a bug in the src rather than the ref. I see the base WriteAsync has the default parameter https://github.com/dotnet/runtime/blob/4da708a7060d238354d79823e58839c1d92f7fd1/src/libraries/System.Runtime/ref/System.Runtime.cs#L10773

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just about to paste this, you're fast. Yes, the src is wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed the ref.

public override void WriteByte(byte value) { }
}
public partial class GZipStream : System.IO.Stream
Expand Down Expand Up @@ -131,18 +131,30 @@ public enum ZipArchiveMode
Create = 1,
Update = 2,
}
public sealed class ZLibCompressionOptions
public sealed partial class ZLibCompressionOptions
{
public int CompressionLevel { get; set; }
public ZLibCompressionStrategy CompressionStrategy { get; set; }
public ZLibCompressionOptions() { }
public int CompressionLevel { get { throw null; } set { } }
public System.IO.Compression.ZLibCompressionStrategy CompressionStrategy { get { throw null; } set { } }
}
public enum ZLibCompressionStrategy
{
Default = 0,
Filtered = 1,
HuffmanOnly = 2,
RunLengthEncoding = 3,
Fixed = 4
Fixed = 4,
}
public partial class ZLibException : System.IO.IOException, System.Runtime.Serialization.ISerializable
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this was intentionally omitted

<!-- Exposed publicly only in implementation for serialization compat. -->
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.IO.Compression.ZLibException</Target>
</Suppression>

Perhaps you can configure GenAPI so that it will exclude it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me understand how it works first.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll open an issue to keep investigating later #112451

I'll jump to work on the m-p issue.

Copy link
Member

Choose a reason for hiding this comment

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

I added a comment to #112451 (comment) with how to do this. Your call if you want to do it in this PR or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks. I think I should do it in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed the changes. Nice to see that after creating the txt file and adding that property to the csproj, the ZLibException is no longer getting auto-added to the ref cs when running the dotnet msbuild /t:GenerateReferenceAssemblySource command.

{
public ZLibException() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ZLibException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public ZLibException(string? message, System.Exception? innerException) { }
public ZLibException(string? message, string? zlibErrorContext, int zlibErrorCode, string? zlibErrorMessage) { }
[System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { }
}
public sealed partial class ZLibStream : System.IO.Stream
{
Expand Down
Loading