Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb7628f

Browse files
authored
SupportDBNull innetstandard1.3 assembly (#394)
* Support `DBNull` in `netstandard1.3` assembly- available from the System.Data.Common package- extend `DBNull` testing to include `net6.0` - s/NETCOREAPP/NETCOREAPP2_1/ where possible- fix comments in `HttpValueCollectionTest` - comments about `DBNull` there were incorrect* !fixup! Add `$(System.JobId)` to artifact names- `publish` / `PublishPipelineArtifact@1` task doesn't overwrite an existing build artifact - bit different from `PublishBuildArtifacts@1`- follow guidance at <https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml-task#q-can-i-delete-pipeline-artifacts-when-re-running-failed-jobs>
1 parentd56a97f commitcb7628f

File tree

8 files changed

+13
-18
lines changed

8 files changed

+13
-18
lines changed

‎azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
displayName:Build
8080

8181
-publish:./bin/$(_Configuration)/Test/TestResults/
82-
artifact:$(_Configuration) Test Results
82+
artifact:$(_Configuration) Test Results $(System.JobId)
8383
condition:and(always(), ne(variables._BuildTarget, 'Build'))
8484
continueOnError:true
8585
displayName:Upload test results
@@ -95,6 +95,6 @@ jobs:
9595
testRunTitle:$(_Configuration)
9696

9797
-publish:./artifacts/
98-
artifact:$(_Configuration) Logs
98+
artifact:$(_Configuration) Logs $(System.JobId)
9999
condition:always()
100100
displayName:Upload logs

‎src/System.Net.Http.Formatting.ns1_3/System.Net.Http.Formatting.ns1_3.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<ItemGroup>
1818
<PackageReferenceInclude="System.Collections.Specialized"Version="4.3.0" />
1919
<PackageReferenceInclude="System.ComponentModel.EventBasedAsync"Version="4.3.0" />
20+
<PackageReferenceInclude="System.Data.Common"Version="4.3.0" />
2021
<PackageReferenceInclude="System.Diagnostics.Contracts"Version="4.3.0" />
2122
<PackageReferenceInclude="System.Memory"Version="4.5.5" />
2223
<PackageReferenceInclude="System.Runtime.Serialization.Json"Version="4.3.0" />

‎src/System.Net.Http.Formatting/Formatting/BsonMediaTypeFormatter.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public sealed override int MaxDepth
7373
}
7474
}
7575

76-
#if!NETSTANDARD1_3// DBNull not supported in netstandard1.3; no need to override there
7776
/// <inheritdoc />
7877
publicoverrideTask<object>ReadFromStreamAsync(Typetype,StreamreadStream,HttpContentcontent,IFormatterLoggerformatterLogger)
7978
{
@@ -101,7 +100,6 @@ public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, H
101100
returnbase.ReadFromStreamAsync(type,readStream,content,formatterLogger);
102101
}
103102
}
104-
#endif
105103

106104
/// <inheritdoc />
107105
publicoverrideobjectReadFromStream(Typetype,StreamreadStream,EncodingeffectiveEncoding,
@@ -234,14 +232,13 @@ public override void WriteToStream(Type type, object value, Stream writeStream,
234232

235233
if(value==null)
236234
{
237-
// Cannot serialize null at the top level.Json.Net throws Newtonsoft.Json.JsonWriterException : Error
238-
// writing Null value. BSON must start with an Object or Array. Path ''.Fortunately
235+
// Cannot serialize null at the top level. Json.Net throws Newtonsoft.Json.JsonWriterException : Error
236+
// writing Null value. BSON must start with an Object or Array. Path ''. Fortunately
239237
// BaseJsonMediaTypeFormatter.ReadFromStream(Type, Stream, HttpContent, IFormatterLogger) treats zero-
240238
// length content as null or the default value of a struct.
241239
return;
242240
}
243241

244-
#if!NETSTANDARD1_3// DBNull not supported in netstandard1.3
245242
if(value==DBNull.Value)
246243
{
247244
// ReadFromStreamAsync() override above converts null to DBNull.Value if given Type is DBNull; normally
@@ -252,7 +249,6 @@ public override void WriteToStream(Type type, object value, Stream writeStream,
252249
// rather than null, and not meet the receiver's expectations.
253250
return;
254251
}
255-
#endif
256252

257253
// See comments in ReadFromStream() above about this special case and the need to include byte[] in it.
258254
// Using runtime type here because Json.Net will throw during serialization whenever it cannot handle the

‎test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_PerhapsJObjec
392392
}
393393
}
394394

395-
#if!Testing_NetStandard1_3// DBNull not supported in netstandard1.3
396395
// Test alternate null value
397396
[Theory]
398397
[TestDataSet(typeof(JsonMediaTypeFormatterTests),"DBNullAsObjectTestDataCollection",TestDataVariations.AllSingleInstances)]
@@ -408,7 +407,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull(
408407
Assert.Null(readObj);
409408
}
410409

411-
#if!NETCOREAPP// DBNull not serializable on .NET Core 2.1 except at top level (using BsonMediaTypeformatter special case).
410+
#if!NETCOREAPP2_1// DBNull not serializable on .NET Core 2.1 except at top level (using BsonMediaTypeformatter special case).
412411
[Theory]
413412
[TestDataSet(typeof(JsonMediaTypeFormatterTests),"DBNullAsObjectTestDataCollection",TestDataVariations.AsDictionary)]
414413
publicasyncTaskReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull_Dictionary(TypevariationType,objecttestData)
@@ -512,7 +511,6 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNull()
512511
// Only BSON case where DBNull.Value round-trips
513512
Assert.Equal(testData,readObj);
514513
}
515-
#endif
516514

517515
privateclassTestBsonMediaTypeFormatter:BsonMediaTypeFormatter
518516
{

‎test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_KnownTypes(Ty
159159
}
160160
}
161161

162-
#if!NETCOREAPP// DBNull not serializable on .NET Core 2.1.
162+
#if!NETCOREAPP2_1// DBNull not serializable on .NET Core 2.1.
163163
// Test alternate null value
164164
[Fact]
165165
publicasyncTaskReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNull()

‎test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync(Type variatio
367367
}
368368
}
369369

370-
#if!NETCOREAPP// DBNull not serializable on .NET Core 2.1.
370+
#if!NETCOREAPP2_1// DBNull not serializable on .NET Core 2.1.
371371
// Test alternate null value; always serialized as "null"
372372
[Theory]
373373
[TestDataSet(typeof(JsonMediaTypeFormatterTests),"DBNullAsObjectTestDataCollection",TestDataVariations.AllSingleInstances)]

‎test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class XmlMediaTypeFormatterTests : MediaTypeFormatterTestBase<XmlMediaTyp
3636
Int32.MaxValue,
3737
Int64.MinValue,
3838
Int64.MaxValue,
39-
#if!NETCOREAPP// DBNull not serializable on .NET Core 2.1.
39+
#if!NETCOREAPP2_1// DBNull not serializable on .NET Core 2.1.
4040
DBNull.Value,
4141
#endif
4242
});
@@ -478,7 +478,7 @@ public async Task ReadFromStream_AsyncRoundTripsWriteToStreamUsingDataContractSe
478478
}
479479
}
480480

481-
#if!NETCOREAPP// DBNull not serializable on .NET Core 2.1.
481+
#if!NETCOREAPP2_1// DBNull not serializable on .NET Core 2.1.
482482
[Fact]
483483
publicasyncTaskReadFromStreamAsync_RoundTripsWriteToStreamAsyncUsingDataContractSerializer_DBNull()
484484
{

‎test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace System.Net.Http.Internal
1212
{
1313
publicclassHttpValueCollectionTest
1414
{
15-
#if!NETCOREAPP// Unused on .NET Core 2.1.
15+
#if!NETCOREAPP// Unused on .NET Core.
1616
privatestaticreadonlyint_maxCollectionKeys=1000;
1717
#endif
1818

@@ -21,7 +21,7 @@ private static HttpValueCollection CreateInstance()
2121
returnHttpValueCollection.Create();
2222
}
2323

24-
#if!NETCOREAPP
24+
#if!NETCOREAPP// Unsupported on .NET Core.
2525
privatestaticvoidRunInIsolation(Actionaction)
2626
{
2727
AppDomainUtils.RunInSeparateAppDomain(action);
@@ -132,7 +132,7 @@ public void Create_CreatesEmptyCollection()
132132
Assert.Empty(nvc);
133133
}
134134

135-
#if!NETCOREAPP//DBNull not serializable on.NET Core 2.1.
135+
#if!NETCOREAPP//Able to run ona separate AppDomain only on .NET Framework.
136136
// This set of tests requires running on a separate appdomain so we don't
137137
// touch the static property MediaTypeFormatter.MaxHttpCollectionKeys.
138138
[Fact]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp