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

Commit3e2e11b

Browse files
authored
Use Newtonsoft.Json.Bson except in NetCore projects (#370)
- avoid obsolete `BsonReader` and `BsonWriter` classes - use `NETFX_CORE` for remaining legacy case (for now)- remove `NEWTONSOFTJSON10` define; need only `NETFX_CORE` now
1 parentd2c6660 commit3e2e11b

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<OutputPath>$(OutputPath)NetStandard\</OutputPath>
88
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
99
<RunCodeAnalysis>false</RunCodeAnalysis>
10-
<DefineConstants>$(DefineConstants);ASPNETMVC;NEWTONSOFTJSON10</DefineConstants>
10+
<DefineConstants>$(DefineConstants);ASPNETMVC</DefineConstants>
1111
<NoWarn>1591</NoWarn>
1212
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1313
<Configurations>$(Configurations);CodeAnalysis</Configurations>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
usingSystem.Threading.Tasks;
1212
usingSystem.Web.Http;
1313
usingNewtonsoft.Json;
14-
#ifNEWTONSOFTJSON10
14+
#ifNETFX_CORE
15+
usingNewtonsoft.Json.Bson;
16+
#else
1517
usingBsonReader=Newtonsoft.Json.Bson.BsonDataReader;
1618
usingBsonWriter=Newtonsoft.Json.Bson.BsonDataWriter;
17-
#else
18-
usingNewtonsoft.Json.Bson;
1919
#endif
2020

2121
namespaceSystem.Net.Http.Formatting
@@ -200,11 +200,11 @@ public override JsonReader CreateJsonReader(Type type, Stream readStream, Encodi
200200
throwError.ArgumentNull("effectiveEncoding");
201201
}
202202

203-
#if!NEWTONSOFTJSON10
203+
#ifNETFX_CORE
204204
#pragma warning disableCS0618// Type or member is obsolete
205205
#endif
206206
BsonReaderreader=newBsonReader(newBinaryReader(readStream,effectiveEncoding));
207-
#if!NEWTONSOFTJSON10
207+
#ifNETFX_CORE
208208
#pragma warning restoreCS0618// Type or member is obsolete
209209
#endif
210210

@@ -303,11 +303,11 @@ public override JsonWriter CreateJsonWriter(Type type, Stream writeStream, Encod
303303
throwError.ArgumentNull("effectiveEncoding");
304304
}
305305

306-
#if!NEWTONSOFTJSON10
306+
#ifNETFX_CORE
307307
#pragma warning disableCS0618// Type or member is obsolete
308308
#endif
309309
returnnewBsonWriter(newBinaryWriter(writeStream,effectiveEncoding));
310-
#if!NEWTONSOFTJSON10
310+
#ifNETFX_CORE
311311
#pragma warning restoreCS0618// Type or member is obsolete
312312
#endif
313313
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<SpecificVersion>False</SpecificVersion>
2121
<Private>False</Private>
2222
</Reference>
23+
<ReferenceInclude="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
24+
<HintPath>..\..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath>
25+
<SpecificVersion>False</SpecificVersion>
26+
<Private>False</Private>
27+
</Reference>
2328
<ReferenceInclude="System" />
2429
<ReferenceInclude="System.Configuration" />
2530
<ReferenceInclude="System.Core" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<packageid="Newtonsoft.Json"version="13.0.1"targetFramework="net45" />
4+
<packageid="Newtonsoft.Json.Bson"version="1.0.2"targetFramework="net45" />
45
</packages>

‎test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<RootNamespace>System.Net.Http</RootNamespace>
66
<AssemblyName>System.Net.Http.Formatting.NetStandard.Test</AssemblyName>
77
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>
8-
<DefineConstants>$(DefineConstants);NEWTONSOFTJSON10</DefineConstants>
98
<Configurations>$(Configurations);CodeAnalysis</Configurations>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ public async Task FormatterThrowsOnWriteWithInvalidContent()
262262
BsonMediaTypeFormatterformatter=newBsonMediaTypeFormatter();
263263
HttpContentcontent=newStringContent(String.Empty);
264264
MemoryStreamstream=newMemoryStream();
265-
#ifNEWTONSOFTJSON10// Json.NET 10's Bson package calculates the path in some exceptions differently.
266-
stringexpectedPath="Value";
267-
#else
265+
#ifNETFX_CORE// Separate Bson package (not yet used in NETCore project) calculates the path in exceptions differently
268266
stringexpectedPath=string.Empty;
267+
#else
268+
stringexpectedPath="Value";
269269
#endif
270270
stringexpectedMessage=string.Format(
271271
"Value is too large to fit in a signed 32 bit integer. BSON does not support unsigned values. Path '{0}'.",

‎test/System.Net.Http.Formatting.Test/System.Net.Http.Formatting.Test.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
2727
<Private>True</Private>
2828
</Reference>
29+
<ReferenceInclude="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
30+
<HintPath>..\..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath>
31+
<Private>True</Private>
32+
</Reference>
2933
<ReferenceInclude="System" />
3034
<ReferenceInclude="System.Configuration" />
3135
<ReferenceInclude="System.Data" />

‎test/System.Net.Http.Formatting.Test/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<packageid="Castle.Core"version="4.2.1"targetFramework="net452" />
44
<packageid="Moq"version="4.7.142"targetFramework="net452" />
55
<packageid="Newtonsoft.Json"version="13.0.1"targetFramework="net452" />
6+
<packageid="Newtonsoft.Json.Bson"version="1.0.2"targetFramework="net452" />
67
<packageid="xunit"version="2.3.0"targetFramework="net452" />
78
<packageid="xunit.abstractions"version="2.0.1"targetFramework="net452" />
89
<packageid="xunit.analyzers"version="0.7.0"targetFramework="net452" />

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp