Skip to content

Commit e717a84

Browse files
authored
Update last few projects to target netcoreapp3.0 (#5128)
- #3754 - remove `#if`'s for multi-targeting where source is never multi-targeted - left `StreamPipeReader`, `StreamPipeWriter` and their test classes alone because they're moving to CoreFx
1 parent 443b144 commit e717a84

File tree

12 files changed

+4
-173
lines changed

12 files changed

+4
-173
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/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>

src/Shared/CertificateGeneration/CertificateManager.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@ internal class CertificateManager
3232
private const string MacOSSystemKeyChain = "/Library/Keychains/System.keychain";
3333
private static readonly string MacOSUserKeyChain = Environment.GetEnvironmentVariable("HOME") + "/Library/Keychains/login.keychain-db";
3434
private const string MacOSFindCertificateCommandLine = "security";
35-
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0
3635
private static readonly string MacOSFindCertificateCommandLineArgumentsFormat = "find-certificate -c {0} -a -Z -p " + MacOSSystemKeyChain;
37-
#endif
3836
private const string MacOSFindCertificateOutputRegex = "SHA-1 hash: ([0-9A-Z]+)";
3937
private const string MacOSRemoveCertificateTrustCommandLine = "sudo";
4038
private const string MacOSRemoveCertificateTrustCommandLineArgumentsFormat = "security remove-trusted-cert -d {0}";
4139
private const string MacOSDeleteCertificateCommandLine = "sudo";
4240
private const string MacOSDeleteCertificateCommandLineArgumentsFormat = "security delete-certificate -Z {0} {1}";
4341
private const string MacOSTrustCertificateCommandLine = "sudo";
44-
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0
4542
private static readonly string MacOSTrustCertificateCommandLineArguments = "security add-trusted-cert -d -r trustRoot -k " + MacOSSystemKeyChain + " ";
46-
#endif
4743
private const int UserCancelledErrorCode = 1223;
4844

4945
public IList<X509Certificate2> ListCertificates(
@@ -153,8 +149,6 @@ private static void DisposeCertificates(IEnumerable<X509Certificate2> disposable
153149
}
154150
}
155151

156-
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0
157-
158152
public X509Certificate2 CreateAspNetCoreHttpsDevelopmentCertificate(DateTimeOffset notBefore, DateTimeOffset notAfter, string subjectOverride, DiagnosticInformation diagnostics = null)
159153
{
160154
var subject = new X500DistinguishedName(subjectOverride ?? LocalhostHttpsDistinguishedName);
@@ -739,7 +733,7 @@ public EnsureCertificateResult EnsureValidCertificateExists(
739733
return result;
740734
}
741735

742-
// This is just to avoid breaking changes across repos.
736+
// This is just to avoid breaking changes across repos.
743737
// Will be renamed back to EnsureAspNetCoreHttpsDevelopmentCertificate once updates are made elsewhere.
744738
public DetailedEnsureCertificateResult EnsureAspNetCoreHttpsDevelopmentCertificate2(
745739
DateTimeOffset notBefore,
@@ -893,7 +887,6 @@ internal class DetailedEnsureCertificateResult
893887
public EnsureCertificateResult ResultCode { get; set; }
894888
public DiagnosticInformation Diagnostics { get; set; } = new DiagnosticInformation();
895889
}
896-
#endif
897890

898891
internal class DiagnosticInformation
899892
{

src/Shared/CertificateGeneration/EnsureCertificateResult.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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 NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0
5-
64
namespace Microsoft.AspNetCore.Certificates.Generation
75
{
86
internal enum EnsureCertificateResult
@@ -16,5 +14,3 @@ internal enum EnsureCertificateResult
1614
UserCancelledTrustStep
1715
}
1816
}
19-
20-
#endif

src/Tools/FirstRunCertGenerator/test/CertificateManagerTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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-
64
using System;
75
using System.IO;
86
using System.Linq;
@@ -284,5 +282,3 @@ public void EnsureAspNetCoreHttpsDevelopmentCertificate_CanRemoveCertificates()
284282
}
285283
}
286284
}
287-
288-
#endif

0 commit comments

Comments
 (0)