Skip to content

Commit 4c7893e

Browse files
committed
Update last few projects to target netcoreapp3.0
- #3754 - remove `#if`'s for multi-targeting where source is never multi-targeted
1 parent 3c09d64 commit 4c7893e

File tree

16 files changed

+6
-239
lines changed

16 files changed

+6
-239
lines changed

src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/NetCorePbkdf2Provider.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#if NETCOREAPP3_0
5-
// Rfc2898DeriveBytes in .NET Standard 2.0 only supports SHA1
6-
74
using System;
85
using System.Diagnostics;
96
using System.Security.Cryptography;
@@ -64,8 +61,3 @@ private static byte[] DeriveKeyImpl(string password, byte[] salt, KeyDerivationP
6461
}
6562
}
6663
}
67-
68-
#elif NETSTANDARD2_0
69-
#else
70-
#error Update target frameworks
71-
#endif

src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/Pbkdf2Util.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,12 @@ private static IPbkdf2Provider GetPbkdf2Provider()
2525
// acceptable implementation
2626
return new Win7Pbkdf2Provider();
2727
}
28-
#if NETCOREAPP3_0
2928
else
3029
{
3130
// fastest implementation on .NET Core for Linux/macOS.
3231
// Not supported on .NET Framework
3332
return new NetCorePbkdf2Provider();
3433
}
35-
#elif NETSTANDARD2_0
36-
else
37-
{
38-
// slowest implementation
39-
return new ManagedPbkdf2Provider();
40-
}
41-
#else
42-
#error Update target frameworks
43-
#endif
4434
}
4535
}
4636
}

src/DataProtection/Cryptography.KeyDerivation/test/Pbkdf2Tests.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ namespace Microsoft.AspNetCore.Cryptography.KeyDerivation
1212
{
1313
public class Pbkdf2Tests
1414
{
15-
16-
#if NET461
17-
#elif NETCOREAPP3_0
1815
// The 'numBytesRequested' parameters below are chosen to exercise code paths where
1916
// this value straddles the digest length of the PRF. We only use 5 iterations so
2017
// that our unit tests are fast.
@@ -60,9 +57,6 @@ public void RunTest_WithLongPassword_NetCore()
6057
var salt = Encoding.UTF8.GetBytes("abcdefghijkl");
6158
RunTest_WithLongPassword_Impl<NetCorePbkdf2Provider>(salt, "NGJtFzYUaaSxu+3ZsMeZO5d/qPJDUYW4caLkFlaY0cLSYdh1PN4+nHUVp4pUUubJWu3UeXNMnHKNDfnn8GMfnDVrAGTv1lldszsvUJ0JQ6p4+daQEYBc//Tj/ejuB3luwW0IinyE7U/ViOQKbfi5pCZFMQ0FFx9I+eXRlyT+I74=");
6259
}
63-
#else
64-
#error Update target framework
65-
#endif
6660

6761
// The 'numBytesRequested' parameters below are chosen to exercise code paths where
6862
// this value straddles the digest length of the PRF. We only use 5 iterations so

src/DataProtection/DataProtection/test/AnonymousImpersonation.cs

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/DataProtection/DataProtection/test/TypeForwardingActivatorTests.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,7 @@ public void CreateInstance_DoesNotForwardingTypesExternalTypes(Type type)
103103
[MemberData(nameof(AssemblyVersions))]
104104
public void CreateInstance_ForwardsAcrossVersionChanges(Version version)
105105
{
106-
#if NET461
107-
// run this test in an appdomain without testhost's custom assembly resolution hooks
108-
var setupInfo = new AppDomainSetup
109-
{
110-
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
111-
ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
112-
};
113-
var domain = AppDomain.CreateDomain("TestDomain", null, setupInfo);
114-
var wrappedTestClass = (TypeForwardingActivatorTests)domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName, typeof(TypeForwardingActivatorTests).FullName);
115-
wrappedTestClass.CreateInstance_ForwardsAcrossVersionChangesImpl(version);
116-
#elif NETCOREAPP3_0
117106
CreateInstance_ForwardsAcrossVersionChangesImpl(version);
118-
#else
119-
#error Target framework should be updated
120-
#endif
121107
}
122108

123109
private void CreateInstance_ForwardsAcrossVersionChangesImpl(Version newVersion)

src/DataProtection/DataProtection/test/XmlEncryption/DpapiXmlEncryptionTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,5 @@ public void Encrypt_CurrentUserOrLocalMachine_Decrypt_RoundTrips(bool protectToL
3333
var roundTrippedElement = decryptor.Decrypt(encryptedXmlInfo.EncryptedElement);
3434
XmlAssert.Equal(originalXml, roundTrippedElement);
3535
}
36-
37-
#if NET461
38-
[ConditionalFact]
39-
[ConditionalRunTestOnlyOnWindows]
40-
public void Encrypt_CurrentUser_Decrypt_ImpersonatedAsAnonymous_Fails()
41-
{
42-
// Arrange
43-
var originalXml = XElement.Parse(@"<mySecret value='265ee4ea-ade2-43b1-b706-09b259e58b6b' />");
44-
var encryptor = new DpapiXmlEncryptor(protectToLocalMachine: false, loggerFactory: NullLoggerFactory.Instance);
45-
var decryptor = new DpapiXmlDecryptor();
46-
47-
// Act & assert - run through encryptor and make sure we get back an obfuscated element
48-
var encryptedXmlInfo = encryptor.Encrypt(originalXml);
49-
Assert.Equal(typeof(DpapiXmlDecryptor), encryptedXmlInfo.DecryptorType);
50-
Assert.DoesNotContain("265ee4ea-ade2-43b1-b706-09b259e58b6b", encryptedXmlInfo.EncryptedElement.ToString(), StringComparison.OrdinalIgnoreCase);
51-
52-
// Act & assert - run through decryptor (while impersonated as anonymous) and verify failure
53-
ExceptionAssert2.ThrowsCryptographicException(() =>
54-
AnonymousImpersonation.Run(() => decryptor.Decrypt(encryptedXmlInfo.EncryptedElement)));
55-
}
56-
#elif NETCOREAPP3_0
57-
#else
58-
#error Target framework needs to be updated
59-
#endif
6036
}
6137
}

src/Features/JsonPatch/src/Microsoft.AspNetCore.JsonPatch.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>ASP.NET Core support for JSON PATCH.</Description>
5-
<TargetFramework>netstandard2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
<NoWarn>$(NoWarn);CS1591</NoWarn>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;json;jsonpatch</PackageTags>

src/Features/JsonPatch/test/Microsoft.AspNetCore.JsonPatch.Tests.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

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>

src/Http/Http/src/StreamPipeReader.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.IO.Pipelines;
99
using System.Runtime.CompilerServices;
1010
using System.Runtime.ExceptionServices;
11-
using System.Runtime.InteropServices;
1211
using System.Threading;
1312
using System.Threading.Tasks;
1413

@@ -227,18 +226,7 @@ public override async ValueTask<ReadResult> ReadAsync(CancellationToken cancella
227226
try
228227
{
229228
AllocateReadTail();
230-
#if NETCOREAPP3_0
231229
var length = await _readingStream.ReadAsync(_readTail.AvailableMemory.Slice(_readTail.End), tokenSource.Token);
232-
#elif NETSTANDARD2_0
233-
if (!MemoryMarshal.TryGetArray<byte>(_readTail.AvailableMemory.Slice(_readTail.End), out var arraySegment))
234-
{
235-
ThrowHelper.CreateInvalidOperationException_NoArrayFromMemory();
236-
}
237-
238-
var length = await _readingStream.ReadAsync(arraySegment.Array, arraySegment.Offset, arraySegment.Count, tokenSource.Token);
239-
#else
240-
#error Target frameworks need to be updated.
241-
#endif
242230
Debug.Assert(length + _readTail.End <= _readTail.AvailableMemory.Length);
243231

244232
_readTail.End += length;

src/Http/Http/src/StreamPipeWriter.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
using System.IO.Pipelines;
99
using System.Runtime.CompilerServices;
1010
using System.Runtime.ExceptionServices;
11-
using System.Runtime.InteropServices;
1211
using System.Threading;
1312
using System.Threading.Tasks;
1413

1514
namespace Microsoft.AspNetCore.Http
1615
{
1716
/// <summary>
18-
/// Implements PipeWriter using a underlying stream.
17+
/// Implements PipeWriter using a underlying stream.
1918
/// </summary>
2019
public class StreamPipeWriter : PipeWriter, IDisposable
2120
{
@@ -50,7 +49,7 @@ private CancellationTokenSource InternalTokenSource
5049
}
5150

5251
/// <summary>
53-
/// Creates a new StreamPipeWrapper
52+
/// Creates a new StreamPipeWrapper
5453
/// </summary>
5554
/// <param name="writingStream">The stream to write to</param>
5655
public StreamPipeWriter(Stream writingStream) : this(writingStream, 4096)
@@ -174,14 +173,7 @@ private async ValueTask<FlushResult> FlushAsyncInternal(CancellationToken cancel
174173
for (var i = 0; i < count; i++)
175174
{
176175
var segment = _completedSegments[0];
177-
#if NETCOREAPP3_0
178176
await _writingStream.WriteAsync(segment.Buffer.Slice(0, segment.Length), localToken);
179-
#elif NETSTANDARD2_0
180-
MemoryMarshal.TryGetArray<byte>(segment.Buffer, out var arraySegment);
181-
await _writingStream.WriteAsync(arraySegment.Array, 0, segment.Length, localToken);
182-
#else
183-
#error Target frameworks need to be updated.
184-
#endif
185177
_bytesWritten -= segment.Length;
186178
segment.Return();
187179
_completedSegments.RemoveAt(0);
@@ -190,14 +182,7 @@ private async ValueTask<FlushResult> FlushAsyncInternal(CancellationToken cancel
190182

191183
if (!_currentSegment.IsEmpty)
192184
{
193-
#if NETCOREAPP3_0
194185
await _writingStream.WriteAsync(_currentSegment.Slice(0, _position), localToken);
195-
#elif NETSTANDARD2_0
196-
MemoryMarshal.TryGetArray<byte>(_currentSegment, out var arraySegment);
197-
await _writingStream.WriteAsync(arraySegment.Array, 0, _position, localToken);
198-
#else
199-
#error Target frameworks need to be updated.
200-
#endif
201186
_bytesWritten -= _position;
202187
_position = 0;
203188
}

src/Http/Http/test/StreamPipeReaderTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,6 @@ public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
565565
await Task.Yield();
566566
return await base.ReadAsync(buffer, offset, count, cancellationToken);
567567
}
568-
569-
#if NETCOREAPP2_2
570-
public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
571-
{
572-
await Task.Yield();
573-
return await base.ReadAsync(buffer, cancellationToken);
574-
}
575-
#endif
576568
}
577569
}
578570
}

src/Http/Http/test/StreamPipeWriterTests.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
311311
await Task.Delay(30000, cancellationToken);
312312
return 0;
313313
}
314-
#if NETCOREAPP2_2
315-
public override async ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default)
316-
{
317-
await Task.Delay(30000, cancellationToken);
318-
return 0;
319-
}
320-
#endif
321314
}
322315

323316
internal class SingleWriteStream : MemoryStream
@@ -326,28 +319,6 @@ internal class SingleWriteStream : MemoryStream
326319

327320
public bool AllowAllWrites { get; set; }
328321

329-
330-
#if NETCOREAPP2_2
331-
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default)
332-
{
333-
try
334-
{
335-
if (_shouldNextWriteFail && !AllowAllWrites)
336-
{
337-
await Task.Delay(30000, cancellationToken);
338-
}
339-
else
340-
{
341-
await base.WriteAsync(source, cancellationToken);
342-
}
343-
}
344-
finally
345-
{
346-
_shouldNextWriteFail = !_shouldNextWriteFail;
347-
}
348-
}
349-
#endif
350-
351322
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
352323
{
353324
try

src/PackageArchive/ZipManifestGenerator/ZipManifestGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
<SignAssembly>false</SignAssembly>
77
<LangVersion>7.1</LangVersion>
88
<DisableImplicitFrameworkReferences>false</DisableImplicitFrameworkReferences>

0 commit comments

Comments
 (0)