Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a .NET 8 target to RequiredTargetFrameworks #46637

Merged
merged 47 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d580f5e
initial updates
m-redding Oct 15, 2024
1783cbb
Merge branch 'Azure:main' into net8update
m-redding Oct 21, 2024
a5603a2
core libraries
m-redding Oct 21, 2024
70be1f5
provisioning
m-redding Oct 21, 2024
5e5a77d
servicebus
m-redding Oct 21, 2024
40d8b7a
communication
m-redding Oct 21, 2024
2360b14
hold off on API generation
m-redding Oct 21, 2024
26d0a84
one more
m-redding Oct 21, 2024
ed1fc69
move API compat change to be in Directory build common props instead
m-redding Oct 21, 2024
58578aa
identity
m-redding Oct 21, 2024
25e4c63
eventhub
m-redding Oct 21, 2024
360f83a
attestation
m-redding Oct 21, 2024
cfdd05a
tables
m-redding Oct 21, 2024
31267bb
translation
m-redding Oct 21, 2024
92fd10d
batch
m-redding Oct 21, 2024
55ac13b
tables/storage
m-redding Oct 21, 2024
1633a89
temp
m-redding Oct 24, 2024
754c384
open AI fixes
m-redding Oct 25, 2024
d4b6232
open AI fixes
m-redding Oct 28, 2024
0915eec
more fixes
m-redding Oct 28, 2024
1419c0e
Merge branch 'Azure:main' into net8update
m-redding Oct 28, 2024
6ac9055
updates
m-redding Oct 28, 2024
45bccb4
few more exceptions
m-redding Oct 28, 2024
ca726a9
feedback p1
m-redding Oct 30, 2024
6d31953
feedback 2
m-redding Nov 4, 2024
70ce543
more feedback
m-redding Nov 4, 2024
ce4e25a
more updates
m-redding Nov 4, 2024
e736815
fixes
m-redding Nov 4, 2024
dc99086
Merge branch 'Azure:main' into net8update
m-redding Nov 4, 2024
1f1178e
provisioning fix
m-redding Nov 4, 2024
f9bd411
playwright testing fb
m-redding Nov 4, 2024
caf33b6
Merge branch 'Azure:main' into net8update
m-redding Nov 7, 2024
0a8b2dd
fixes
m-redding Nov 7, 2024
f092c0d
feedback
m-redding Nov 13, 2024
daf5b7a
Merge branch 'Azure:main' into net8update
m-redding Nov 13, 2024
6381bfc
updates
m-redding Nov 13, 2024
1b1fc6c
fix
m-redding Nov 13, 2024
0dc4a5b
updates
m-redding Nov 13, 2024
f1289c6
fix
m-redding Nov 13, 2024
1dbeb1d
Merge branch 'main' into net8update
m-redding Nov 13, 2024
03533bc
another fix
m-redding Nov 14, 2024
83b7539
fb
m-redding Nov 14, 2024
ca4062b
Merge branch 'main' into net8update
m-redding Nov 15, 2024
316a658
Merge branch 'main' into net8update
m-redding Nov 15, 2024
6e1bc99
feedback and get latest changes
m-redding Nov 15, 2024
f1c958c
Merge branch 'Azure:main' into net8update
m-redding Nov 18, 2024
634bf0d
maps
m-redding Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<!-- Setup default project properties -->
<PropertyGroup>
<LangVersion>11.0</LangVersion>
<LangVersion>latest</LangVersion>
<!--
Disable NU5105 NuGet Pack warning that the version is SemVer 2.0.
SemVer 2.0 is supported by NuGet since 3.0.0 (July 2015) in some capacity, and fully since 3.5.0 (October 2016).
Expand Down Expand Up @@ -106,6 +106,7 @@
<GenerateAPIListing Condition="'$(GenerateAPIListing)' == '' AND '$(IsShippingClientLibrary)' == 'true'">true</GenerateAPIListing>
<EnableSourceLink Condition="'$(EnableSourceLink)' == ''">true</EnableSourceLink>
<DefineConstants Condition="'$(BuildSnippets)' == 'true'">$(DefineConstants);SNIPPET</DefineConstants>
<ApiCompatBaselineTargetFramework Condition="'$(TargetFramework)' == 'net8.0'">netstandard2.0</ApiCompatBaselineTargetFramework>
m-redding marked this conversation as resolved.
Show resolved Hide resolved
jsquire marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

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

<RequiredTargetFrameworks>net452;netstandard1.4;net461;netstandard2.0</RequiredTargetFrameworks>
<RequiredTargetFrameworks Condition="'$(SupportsNetStandard20)' == 'true'">netstandard2.0</RequiredTargetFrameworks>
<RequiredTargetFrameworks Condition="'$(SupportsNetStandard20)' == 'true'">net8.0;netstandard2.0</RequiredTargetFrameworks>
jsquire marked this conversation as resolved.
Show resolved Hide resolved
m-redding marked this conversation as resolved.
Show resolved Hide resolved
<RequiredTargetFrameworks Condition="'$(IsGeneratorLibrary)' == 'true'">net8.0</RequiredTargetFrameworks>
</PropertyGroup>

Expand Down
9 changes: 9 additions & 0 deletions eng/Directory.Build.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@

</ItemGroup>

<!-- Remove packages built into the .NET 6+ runtime -->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<PackageReference Remove="System.Buffers" />
<PackageReference Remove="System.Net.Http" />
<PackageReference Remove="System.Threading.Channels" />
<PackageReference Remove="System.Text.Encodings.Web" />
<PackageReference Remove="System.Text.Json" />
m-redding marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<!-- Add Package Icon to DataPlane Packages -->
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<None Include="$(PackageIconPath)" Pack="true" PackagePath=""/>
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/CodeChecks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ try {
& $PSScriptRoot\Update-Snippets.ps1 -ServiceDirectory $ServiceDirectory
}

Write-Host "Re-generating listings"
Invoke-Block {
& $PSScriptRoot\Export-API.ps1 -ServiceDirectory $ServiceDirectory -SDKType $SDKType -SpellCheckPublicApiSurface:$SpellCheckPublicApiSurface
}
# Write-Host "Re-generating listings"
m-redding marked this conversation as resolved.
Show resolved Hide resolved
# Invoke-Block {
# & $PSScriptRoot\Export-API.ps1 -ServiceDirectory $ServiceDirectory -SDKType $SDKType -SpellCheckPublicApiSurface:$SpellCheckPublicApiSurface
# }

Write-Host "Validating installation instructions"
Join-Path "$PSScriptRoot/../../sdk" $ServiceDirectory `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,11 @@ private bool ValidateTokenSignature(AttestationSigner[] possibleSigners)
{
// The leaf certificate is defined as the certificate which signed the token, so we just need to look
// at the first certificate in the chain.
#if NET6_0_OR_GREATER
m-redding marked this conversation as resolved.
Show resolved Hide resolved
AsymmetricAlgorithm asymmetricAlgorithm = signer.SigningCertificates[0].GetRSAPublicKey();
#else
AsymmetricAlgorithm asymmetricAlgorithm = signer.SigningCertificates[0].PublicKey.Key;
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
if (asymmetricAlgorithm is RSA rsaKey)
{
signatureValidated = rsaKey.VerifyData(
Expand Down Expand Up @@ -645,7 +649,11 @@ private static string GenerateSecuredJsonWebToken(BinaryData body, AttestationTo
AsymmetricAlgorithm signer;
if (signingKey.Certificate.HasPrivateKey)
{
#if NET6_0_OR_GREATER
signer = signingKey.Certificate.GetRSAPrivateKey();
#else
signer = signingKey.Certificate.PrivateKey;
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public AttestationTokenSigningKey(X509Certificate2 certificate)
{
throw new ArgumentException($"Certificate provided {certificate.ToString()} does not have a private key.");
}
#if NET6_0_OR_GREATER
Signer = certificate.GetRSAPublicKey();
#else
Signer = certificate.PrivateKey;
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
Certificate = certificate;
VerifySignerMatchesCertificate(Signer, Certificate);
}
Expand All @@ -62,17 +66,26 @@ public AttestationTokenSigningKey(X509Certificate2 certificate)

private static void VerifySignerMatchesCertificate(AsymmetricAlgorithm signer, X509Certificate2 certificate)
{
if (!signer.KeyExchangeAlgorithm.StartsWith(certificate.PublicKey.Key.KeyExchangeAlgorithm, System.StringComparison.Ordinal))
#if NET6_0_OR_GREATER
AsymmetricAlgorithm publicKey = certificate.GetRSAPublicKey();
#else
AsymmetricAlgorithm publicKey = certificate.PublicKey.Key;
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
if (!signer.KeyExchangeAlgorithm.StartsWith(publicKey.KeyExchangeAlgorithm, System.StringComparison.Ordinal))
{
throw new ArgumentException($"Signer key algorithm {signer.SignatureAlgorithm} does not match certificate key algorithm {certificate.PublicKey.Key.SignatureAlgorithm}");
throw new ArgumentException($"Signer key algorithm {signer.SignatureAlgorithm} does not match certificate key algorithm {publicKey.SignatureAlgorithm}");
}

// Try to match the public key in the certificate and the signer. If the platform
// supports the ToXmlString API, then use that since it the simplest solution and is relatively fast.
try
{
string signerKey = signer.ToXmlString(false);
#if NET6_0_OR_GREATER
string certificateKey = certificate.GetRSAPublicKey().ToXmlString(false);
#else
string certificateKey = certificate.PublicKey.Key.ToXmlString(false);
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
if (signerKey != certificateKey)
{
throw new ArgumentException($"Signer key {signerKey} does not match certificate key {certificateKey}");
Expand All @@ -98,7 +111,7 @@ private static void VerifySignerMatchesCertificate(AsymmetricAlgorithm signer, X
throw new ArgumentException("Signing Key must be either RSA or ECDsa. Unknown signing key found");
}

AsymmetricAlgorithm verifyingAlgorithm = certificate.PublicKey.Key;
AsymmetricAlgorithm verifyingAlgorithm = publicKey;
if (verifyingAlgorithm is RSA verifyingRsa)
{
if (!verifyingRsa.VerifyData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void BuildCanonicalizedResource(StringBuilder stringBuilder, Uri resourc
private string ComputeSasSignature(string message)
{
#if NET6_0_OR_GREATER
return Convert.ToBase64String(HMACSHA256.HashData(AccountKeyValue, Encoding.UTF8.GetBytes(message)));
return Convert.ToBase64String(HMACSHA256.HashData(AccountKey, Encoding.UTF8.GetBytes(message)));
#else
return Convert.ToBase64String(new HMACSHA256(AccountKey).ComputeHash(Encoding.UTF8.GetBytes(message)));
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal bool TryGetAndRemoveEvent(Func<CallAutomationEventBase, bool> predicate
{
// Match any event that matches in the events backlog
var matchingKvp = _eventBacklog.FirstOrDefault(kvp => predicate(kvp.Value.Item1));
matchingEvent = default;

// Try remove the item - if successful, return it as keyValuePair
if (matchingKvp.Key != default && _eventBacklog.TryRemove(matchingKvp.Key, out var returnedValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public ScheduledAction(Action action, TimeSpan period)
public void Dispose()
=> _timer.Dispose();

private void OnTimerTick(object _)
private void OnTimerTick(object? _)
m-redding marked this conversation as resolved.
Show resolved Hide resolved
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Azure.Core.Amqp
public AmqpAddress(string address) { throw null; }
public bool Equals(Azure.Core.Amqp.AmqpAddress other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public override bool Equals(object? obj) { throw null; }
public bool Equals(string other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
Expand Down Expand Up @@ -65,7 +65,7 @@ internal AmqpMessageHeader() { }
public AmqpMessageId(string messageId) { throw null; }
public bool Equals(Azure.Core.Amqp.AmqpMessageId other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public override bool Equals(object? obj) { throw null; }
public bool Equals(string other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.Amqp/src/AmqpAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override string ToString() =>
/// <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.
/// </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
public override bool Equals(object? obj)
m-redding marked this conversation as resolved.
Show resolved Hide resolved
{
if (obj is AmqpAddress address)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.Amqp/src/AmqpMessageId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public AmqpMessageId(string messageId)
/// <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.
/// </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is AmqpMessageId messageId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private sealed class StraightCastFlag<T> : TypeFlag<T>
public static StraightCastFlag<T> Instance { get; } = new();

public override T To(in Variant value)
=> Unsafe.As<Union, T>(ref Unsafe.AsRef(value._union));
=> Unsafe.As<Union, T>(ref Unsafe.AsRef(in value._union));
m-redding marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Loading
Loading