Skip to content

Commit c55dd95

Browse files
authored
[releaes/3.2.8] Get builds working again (#302)
- test using netcoreapp2.1 - react to .NET Core breaking change - see https://docs.microsoft.com/en-us/dotnet/core/compatibility/2.1#path-apis-dont-throw-an-exception-for-invalid-characters - suppress NU5125 warnings - break the build because warnings are treated as errors - do not validate Expires header values - #263
1 parent bc83a3a commit c55dd95

File tree

13 files changed

+32
-18
lines changed

13 files changed

+32
-18
lines changed

src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
namespace System.Net.Http.Formatting.Parsers
1111
{
1212
/// <summary>
13-
/// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header
14-
/// fields used in HTTP and MIME message entities.
13+
/// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header
14+
/// fields used in HTTP and MIME message entities.
1515
/// </summary>
1616
internal class InternetMessageFormatHeaderParser
1717
{
@@ -76,7 +76,7 @@ private enum HeaderFieldState
7676

7777
/// <summary>
7878
/// Parse a buffer of RFC 5322 style header fields and add them to the <see cref="HttpHeaders"/> collection.
79-
/// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be
79+
/// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be
8080
/// present in the buffer.
8181
/// </summary>
8282
/// <param name="buffer">Request buffer from where request is read</param>
@@ -283,7 +283,7 @@ private static ParserState ParseHeaderFields(
283283
}
284284

285285
/// <summary>
286-
/// Maintains information about the current header field being parsed.
286+
/// Maintains information about the current header field being parsed.
287287
/// </summary>
288288
private class CurrentHeaderFieldStore
289289
{
@@ -320,6 +320,10 @@ public void CopyTo(HttpHeaders headers, bool ignoreHeaderValidation)
320320
{
321321
var name = _name.ToString();
322322
var value = _value.ToString().Trim(CurrentHeaderFieldStore._linearWhiteSpace);
323+
if (string.Equals("expires", name, StringComparison.OrdinalIgnoreCase))
324+
{
325+
ignoreHeaderValidation = true;
326+
}
323327

324328
if (ignoreHeaderValidation)
325329
{

src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
1212
<CodeAnalysisRuleSet>..\..\Strict.ruleset</CodeAnalysisRuleSet>
1313
<MyType>Windows</MyType>
14+
<!-- Ignore warning about deprecated <licenseUrl> in the .nuspec. -->
15+
<NoWarn Condition=" '$(MSBuildRuntimeType)' == 'core' ">$(NoWarn);NU5125</NoWarn>
1416
</PropertyGroup>
1517
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1618
<DefineDebug>true</DefineDebug>

src/WebApiHelpPage/WebApiHelpPage.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<CodeAnalysisRuleSet>..\Strict.ruleset</CodeAnalysisRuleSet>
1414
<DefineConstants>$(DefineConstants);ASPNETMVC</DefineConstants>
1515
<NoWarn>1591</NoWarn>
16+
<!-- Ignore warning about deprecated <licenseUrl> in the .nuspec. -->
17+
<NoWarn Condition=" '$(MSBuildRuntimeType)' == 'core' ">$(NoWarn);NU5125</NoWarn>
1618
</PropertyGroup>
1719
<ItemGroup>
1820
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">

test/Microsoft.TestCommon/PlatformInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private static Platform GetPlatform()
2626
{
2727
if (Type.GetType(_netCore20TypeName, throwOnError: false) != null)
2828
{
29-
// Treat .NET Core 2.0 as a .NET 4.5 superset though internal types are different.
29+
// Treat .NET Core 2.1 as a .NET 4.5 superset though internal types are different.
3030
return Platform.Net45;
3131
}
3232

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
55
<RootNamespace>System.Net.Http</RootNamespace>
66
<AssemblyName>System.Net.Http.Formatting.NetStandard.Test</AssemblyName>
77
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>

test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ public static TheoryDataSet<string, string, bool> ReadAndWriteCorrectCharacterEn
302302
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true },
303303
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true },
304304
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false },
305-
#if !NETCOREAPP2_0 // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.0.
305+
#if !NETCOREAPP // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.1.
306306
{ "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false },
307307
#endif
308308
{ "This is a test æøå string written using iso-8859-1", "iso-8859-1", false },
309-
#if !NETCOREAPP2_0
309+
#if !NETCOREAPP
310310
{ "This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false },
311311
#endif
312312
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull(
415415
Assert.Null(readObj);
416416
}
417417

418-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0 except at top level (using BsonMediaTypeformatter special case).
418+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1 except at top level (using BsonMediaTypeformatter special case).
419419
[Theory]
420420
[TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AsDictionary)]
421421
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull_Dictionary(Type variationType, object testData)

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

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

160-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
160+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
161161
// Test alternate null value
162162
[Fact]
163163
public async Task ReadFromStreamAsync_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
@@ -374,7 +374,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync(Type variatio
374374
}
375375
}
376376

377-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
377+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
378378
// Test alternate null value; always serialized as "null"
379379
[Theory]
380380
[TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AllSingleInstances)]

test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public Task DeserializingDeepArraysThrows()
258258
// low surrogate not preceded by high surrogate
259259
[InlineData("ABC \\udc00\\ud800 DEF", "ABC \ufffd\ufffd DEF")]
260260
// make sure unencoded invalid surrogate characters don't make it through
261-
#if NETCOREAPP2_0 // Json.NET uses its regular invalid Unicode character on .NET Core 2.0; '?' elsewhere.
261+
#if NETCOREAPP // Json.NET uses its regular invalid Unicode character on .NET Core 2.1; '?' elsewhere.
262262
[InlineData("\udc00\ud800\ud800", "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd")]
263263
#else
264264
[InlineData("\udc00\ud800\ud800", "??????")]

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 !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
39+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
4040
DBNull.Value,
4141
#endif
4242
});
@@ -484,7 +484,7 @@ public async Task ReadFromStream_AsyncRoundTripsWriteToStreamUsingDataContractSe
484484
}
485485
}
486486

487-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
487+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
488488
[Fact]
489489
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsyncUsingDataContractSerializer_DBNull()
490490
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace System.Net.Http.Internal
1414
{
1515
public class HttpValueCollectionTest
1616
{
17-
#if !NETCOREAPP2_0 // Unused on .NET Core 2.0.
17+
#if !NETCOREAPP // Unused on .NET Core 2.1.
1818
private static readonly int _maxCollectionKeys = 1000;
1919
#endif
2020

@@ -148,7 +148,7 @@ public void Create_CreatesEmptyCollection()
148148
Assert.Empty(nvc);
149149
}
150150

151-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
151+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
152152
// This set of tests requires running on a separate appdomain so we don't
153153
// touch the static property MediaTypeFormatter.MaxHttpCollectionKeys.
154154
[Fact]

test/System.Net.Http.Formatting.Test/MultipartFileStreamProviderTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class MultipartFileStreamProviderTests : MultipartStreamProviderTestBase<
3232
private const int ValidBufferSize = 0x111;
3333
private const string ValidPath = @"c:\some\path";
3434

35+
#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs.
3536
public static TheoryDataSet<string> NotSupportedFilePaths
3637
{
3738
get
@@ -44,6 +45,7 @@ public static TheoryDataSet<string> NotSupportedFilePaths
4445
};
4546
}
4647
}
48+
#endif
4749

4850
public static TheoryDataSet<string> InvalidFilePaths
4951
{
@@ -52,15 +54,17 @@ public static TheoryDataSet<string> InvalidFilePaths
5254
return new TheoryDataSet<string>
5355
{
5456
"",
55-
" ",
57+
" ",
5658
" ",
57-
"\t\t \n ",
59+
#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs.
60+
"\t\t \n ",
5861
"c:\\a<b",
5962
"c:\\a>b",
6063
"c:\\a\"b",
6164
"c:\\a\tb",
6265
"c:\\a|b",
6366
"c:\\a\bb",
67+
#endif
6468
"c:\\a\0b",
6569
"c :\\a\0b",
6670
};
@@ -73,12 +77,14 @@ public void Constructor_ThrowsOnNullRootPath()
7377
Assert.ThrowsArgumentNull(() => { new MultipartFileStreamProvider(null); }, "rootPath");
7478
}
7579

80+
#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs.
7681
[Theory]
7782
[PropertyData("NotSupportedFilePaths")]
7883
public void Constructor_ThrowsOnNotSupportedRootPath(string notSupportedPath)
7984
{
8085
Assert.Throws<NotSupportedException>(() => new MultipartFileStreamProvider(notSupportedPath, ValidBufferSize));
8186
}
87+
#endif
8288

8389
[Theory]
8490
[PropertyData("InvalidFilePaths")]

0 commit comments

Comments
 (0)