Skip to content

Commit 7ff4989

Browse files
committed
net fw compilaris
1 parent 4635ab6 commit 7ff4989

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/libraries/System.Net.Http.Json/src/Resources/Strings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,7 @@
132132
<data name="SerializeWrongType" xml:space="preserve">
133133
<value>The specified type {0} must derive from the specific value's type {1}.</value>
134134
</data>
135-
</root>
135+
<data name="SyncNotSupported" xml:space="preserve">
136+
<value>Synchronous serialization of JsonContent is not supported.</value>
137+
</data>
138+
</root>

src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ private async Task SerializeToStreamAsyncCore(Stream targetStream, bool async, C
116116
}
117117
else
118118
{
119+
#if NETCOREAPP
119120
// Have to use Utf8JsonWriter because JsonSerializer doesn't support sync serialization into stream directly.
120121
using Utf8JsonWriter writer = new Utf8JsonWriter(targetStream);
121122
JsonSerializer.Serialize(writer, Value, ObjectType, _jsonSerializerOptions);
123+
#else
124+
throw new NotSupportedException(SR.SyncNotSupported);
125+
#endif
122126
}
123127
}
124128
}

src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NoWriteNoSeekStreamContent.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ internal NoWriteNoSeekStreamContent(Stream content)
2626
_content = content;
2727
}
2828

29-
protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context) =>
30-
SerializeToStreamAsyncCore(stream, context, async: true, CancellationToken.None);
31-
3229
#if NETCOREAPP
33-
protected override void SerializeToStream(Stream stream, TransportContext context, CancellationToken cancellationToken) =>
34-
SerializeToStreamAsyncCore(stream, context, async: true, cancellationToken);
35-
3630
protected override void SerializeToStream(Stream stream, TransportContext? context, CancellationToken cancellationToken) =>
3731
SerializeToStreamAsyncCore(stream, context, async: false, cancellationToken).GetAwaiter().GetResult();
32+
33+
protected override void SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken) =>
34+
SerializeToStreamAsyncCore(stream, context, async: true, cancellationToken);
3835
#endif
3936

37+
protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context) =>
38+
SerializeToStreamAsyncCore(stream, context, async: true, CancellationToken.None);
39+
4040
private Task SerializeToStreamAsyncCore(Stream stream, TransportContext? context, bool async, CancellationToken cancellationToken)
4141
{
4242
Debug.Assert(stream != null);
@@ -81,6 +81,7 @@ private Task SerializeToStreamAsyncCore(Stream stream, TransportContext? context
8181
}
8282
return copyTask;
8383
}
84+
8485
protected override bool TryComputeLength(out long length)
8586
{
8687
length = 0;

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected override void SerializeToStream(Stream stream, TransportContext? conte
126126
{
127127
using (Stream decompressedStream = CreateContentReadStream(cancellationToken))
128128
{
129-
decompressedStream.CopyTo(stream, cancellationToken);
129+
decompressedStream.CopyTo(stream);
130130
}
131131
}
132132

0 commit comments

Comments
 (0)