Skip to content

Commit d8f5034

Browse files
authored
Add a .NET 8 target to RequiredTargetFrameworks (#46637)
* initial updates * core libraries * provisioning * servicebus * communication * hold off on API generation * one more * move API compat change to be in Directory build common props instead * identity * eventhub * attestation * tables * translation * batch * tables/storage * temp * open AI fixes * open AI fixes * more fixes * updates * few more exceptions * feedback p1 * feedback 2 * more feedback * more updates * fixes * provisioning fix * playwright testing fb * fixes * feedback * updates * updates * fix * another fix * fb * feedback and get latest changes * maps
1 parent 84dda33 commit d8f5034

File tree

59 files changed

+258
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+258
-154
lines changed

eng/Directory.Build.Common.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<!-- Setup default project properties -->
3131
<PropertyGroup>
32-
<LangVersion>11.0</LangVersion>
32+
<LangVersion>latest</LangVersion>
3333
<!--
3434
Disable NU5105 NuGet Pack warning that the version is SemVer 2.0.
3535
SemVer 2.0 is supported by NuGet since 3.0.0 (July 2015) in some capacity, and fully since 3.5.0 (October 2016).
@@ -106,6 +106,7 @@
106106
<GenerateAPIListing Condition="'$(GenerateAPIListing)' == '' AND '$(IsShippingClientLibrary)' == 'true'">true</GenerateAPIListing>
107107
<EnableSourceLink Condition="'$(EnableSourceLink)' == ''">true</EnableSourceLink>
108108
<DefineConstants Condition="'$(BuildSnippets)' == 'true'">$(DefineConstants);SNIPPET</DefineConstants>
109+
<ApiCompatBaselineTargetFramework Condition="'$(TargetFramework)' == 'net8.0'">netstandard2.0</ApiCompatBaselineTargetFramework>
109110
</PropertyGroup>
110111

111112
<PropertyGroup Condition="'$(IsShippingClientLibrary)' == 'true' and '$(TF_BUILD)' == 'true'">
@@ -135,7 +136,7 @@
135136
<SupportsNetStandard20 Condition="'$(SupportsNetStandard20)' == ''">false</SupportsNetStandard20>
136137

137138
<RequiredTargetFrameworks>net452;netstandard1.4;net461;netstandard2.0</RequiredTargetFrameworks>
138-
<RequiredTargetFrameworks Condition="'$(SupportsNetStandard20)' == 'true'">netstandard2.0</RequiredTargetFrameworks>
139+
<RequiredTargetFrameworks Condition="'$(SupportsNetStandard20)' == 'true'">net8.0;netstandard2.0</RequiredTargetFrameworks>
139140
<RequiredTargetFrameworks Condition="'$(IsGeneratorLibrary)' == 'true'">net8.0</RequiredTargetFrameworks>
140141
</PropertyGroup>
141142

eng/Directory.Build.Common.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@
9898

9999
</ItemGroup>
100100

101+
<!-- Remove packages built into the .NET 6+ runtime -->
102+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
103+
<PackageReference Remove="System.Buffers" />
104+
<PackageReference Remove="System.Net.Http" />
105+
<PackageReference Remove="System.Threading.Channels" />
106+
<PackageReference Remove="System.Text.Encodings.Web" />
107+
<PackageReference Remove="System.Text.Json" />
108+
</ItemGroup>
109+
101110
<!-- Add Package Icon to DataPlane Packages -->
102111
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
103112
<None Include="$(PackageIconPath)" Pack="true" PackagePath=""/>

eng/scripts/CodeChecks.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ try {
107107
& $PSScriptRoot\Update-Snippets.ps1 -ServiceDirectory $ServiceDirectory
108108
}
109109

110-
Write-Host "Re-generating listings"
111-
Invoke-Block {
112-
& $PSScriptRoot\Export-API.ps1 -ServiceDirectory $ServiceDirectory -SDKType $SDKType -SpellCheckPublicApiSurface:$SpellCheckPublicApiSurface
113-
}
110+
# Write-Host "Re-generating listings"
111+
# Invoke-Block {
112+
# & $PSScriptRoot\Export-API.ps1 -ServiceDirectory $ServiceDirectory -SDKType $SDKType -SpellCheckPublicApiSurface:$SpellCheckPublicApiSurface
113+
# }
114114

115115
Write-Host "Validating installation instructions"
116116
Join-Path "$PSScriptRoot/../../sdk" $ServiceDirectory `

sdk/attestation/Azure.Security.Attestation/src/AttestationToken.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,11 @@ private bool ValidateTokenSignature(AttestationSigner[] possibleSigners)
448448
{
449449
// The leaf certificate is defined as the certificate which signed the token, so we just need to look
450450
// at the first certificate in the chain.
451+
#if NET6_0_OR_GREATER
452+
AsymmetricAlgorithm asymmetricAlgorithm = signer.SigningCertificates[0].GetRSAPublicKey();
453+
#else
451454
AsymmetricAlgorithm asymmetricAlgorithm = signer.SigningCertificates[0].PublicKey.Key;
455+
#endif
452456
if (asymmetricAlgorithm is RSA rsaKey)
453457
{
454458
signatureValidated = rsaKey.VerifyData(
@@ -645,7 +649,11 @@ private static string GenerateSecuredJsonWebToken(BinaryData body, AttestationTo
645649
AsymmetricAlgorithm signer;
646650
if (signingKey.Certificate.HasPrivateKey)
647651
{
652+
#if NET6_0_OR_GREATER
653+
signer = signingKey.Certificate.GetRSAPrivateKey();
654+
#else
648655
signer = signingKey.Certificate.PrivateKey;
656+
#endif
649657
}
650658
else
651659
{

sdk/attestation/Azure.Security.Attestation/src/Models/AttestationTokenSigningKey.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public AttestationTokenSigningKey(X509Certificate2 certificate)
4545
{
4646
throw new ArgumentException($"Certificate provided {certificate.ToString()} does not have a private key.");
4747
}
48+
#if NET6_0_OR_GREATER
49+
Signer = certificate.GetRSAPublicKey();
50+
#else
4851
Signer = certificate.PrivateKey;
52+
#endif
4953
Certificate = certificate;
5054
VerifySignerMatchesCertificate(Signer, Certificate);
5155
}
@@ -62,17 +66,26 @@ public AttestationTokenSigningKey(X509Certificate2 certificate)
6266

6367
private static void VerifySignerMatchesCertificate(AsymmetricAlgorithm signer, X509Certificate2 certificate)
6468
{
65-
if (!signer.KeyExchangeAlgorithm.StartsWith(certificate.PublicKey.Key.KeyExchangeAlgorithm, System.StringComparison.Ordinal))
69+
#if NET6_0_OR_GREATER
70+
AsymmetricAlgorithm publicKey = certificate.GetRSAPublicKey();
71+
#else
72+
AsymmetricAlgorithm publicKey = certificate.PublicKey.Key;
73+
#endif
74+
if (!signer.KeyExchangeAlgorithm.StartsWith(publicKey.KeyExchangeAlgorithm, System.StringComparison.Ordinal))
6675
{
67-
throw new ArgumentException($"Signer key algorithm {signer.SignatureAlgorithm} does not match certificate key algorithm {certificate.PublicKey.Key.SignatureAlgorithm}");
76+
throw new ArgumentException($"Signer key algorithm {signer.SignatureAlgorithm} does not match certificate key algorithm {publicKey.SignatureAlgorithm}");
6877
}
6978

7079
// Try to match the public key in the certificate and the signer. If the platform
7180
// supports the ToXmlString API, then use that since it the simplest solution and is relatively fast.
7281
try
7382
{
7483
string signerKey = signer.ToXmlString(false);
84+
#if NET6_0_OR_GREATER
85+
string certificateKey = certificate.GetRSAPublicKey().ToXmlString(false);
86+
#else
7587
string certificateKey = certificate.PublicKey.Key.ToXmlString(false);
88+
#endif
7689
if (signerKey != certificateKey)
7790
{
7891
throw new ArgumentException($"Signer key {signerKey} does not match certificate key {certificateKey}");
@@ -98,7 +111,7 @@ private static void VerifySignerMatchesCertificate(AsymmetricAlgorithm signer, X
98111
throw new ArgumentException("Signing Key must be either RSA or ECDsa. Unknown signing key found");
99112
}
100113

101-
AsymmetricAlgorithm verifyingAlgorithm = certificate.PublicKey.Key;
114+
AsymmetricAlgorithm verifyingAlgorithm = publicKey;
102115
if (verifyingAlgorithm is RSA verifyingRsa)
103116
{
104117
if (!verifyingRsa.VerifyData(

sdk/batch/Azure.Compute.Batch/src/Custom/BatchNamedKeyCredentialPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private void BuildCanonicalizedResource(StringBuilder stringBuilder, Uri resourc
178178
private string ComputeSasSignature(string message)
179179
{
180180
#if NET6_0_OR_GREATER
181-
return Convert.ToBase64String(HMACSHA256.HashData(AccountKeyValue, Encoding.UTF8.GetBytes(message)));
181+
return Convert.ToBase64String(HMACSHA256.HashData(AccountKey, Encoding.UTF8.GetBytes(message)));
182182
#else
183183
return Convert.ToBase64String(new HMACSHA256(AccountKey).ComputeHash(Encoding.UTF8.GetBytes(message)));
184184
#endif

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationEventProcessor/EventBacklog.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ internal bool TryGetAndRemoveEvent(Func<CallAutomationEventBase, bool> predicate
5252
{
5353
// Match any event that matches in the events backlog
5454
var matchingKvp = _eventBacklog.FirstOrDefault(kvp => predicate(kvp.Value.Item1));
55+
matchingEvent = default;
5556

5657
// Try remove the item - if successful, return it as keyValuePair
5758
if (matchingKvp.Key != default && _eventBacklog.TryRemove(matchingKvp.Key, out var returnedValue))

sdk/communication/Azure.Communication.Common/src/ThreadSafeRefreshableAccessTokenCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public ScheduledAction(Action action, TimeSpan period)
210210
public void Dispose()
211211
=> _timer.Dispose();
212212

213-
private void OnTimerTick(object _)
213+
private void OnTimerTick(object? _)
214214
{
215215
try
216216
{

sdk/core/Azure.Core.Amqp/api/Azure.Core.Amqp.netstandard2.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Azure.Core.Amqp
88
public AmqpAddress(string address) { throw null; }
99
public bool Equals(Azure.Core.Amqp.AmqpAddress other) { throw null; }
1010
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
11-
public override bool Equals(object obj) { throw null; }
11+
public override bool Equals(object? obj) { throw null; }
1212
public bool Equals(string other) { throw null; }
1313
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
1414
public override int GetHashCode() { throw null; }
@@ -65,7 +65,7 @@ internal AmqpMessageHeader() { }
6565
public AmqpMessageId(string messageId) { throw null; }
6666
public bool Equals(Azure.Core.Amqp.AmqpMessageId other) { throw null; }
6767
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
68-
public override bool Equals(object obj) { throw null; }
68+
public override bool Equals(object? obj) { throw null; }
6969
public bool Equals(string other) { throw null; }
7070
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
7171
public override int GetHashCode() { throw null; }

sdk/core/Azure.Core.Amqp/src/AmqpAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override string ToString() =>
4444
/// <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.
4545
/// </returns>
4646
[EditorBrowsable(EditorBrowsableState.Never)]
47-
public override bool Equals(object obj)
47+
public override bool Equals(object? obj)
4848
{
4949
if (obj is AmqpAddress address)
5050
{

0 commit comments

Comments
 (0)