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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
45 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
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>12.0</LangVersion>
m-redding marked this conversation as resolved.
Show resolved Hide resolved
<!--
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
14 changes: 12 additions & 2 deletions eng/Directory.Build.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
<Error Condition="'@(MissingTargetFrameworks)' != ''" Text="Missing required target frameworks '@(MissingTargetFrameworks)'. Please ensure you add those frameworks." />
</Target>

<Target Name="ValidateRunApiCompat" BeforeTargets="Build" Condition="'$(ValidateRunApiCompat)' == 'true'">
<!-- TEMPORARY while transitioning to require a .NET 8 target, once libraries with new targets have had a chance to release, this can be restored -->
<!-- <Target Name="ValidateRunApiCompat" BeforeTargets="Build" Condition="'$(ValidateRunApiCompat)' == 'true'">
<Error Condition="'$(RunApiCompat)' == 'false' and '$(IncludeBuildOutput)' != 'false'"
Text="Api Compat cannot be disabled."/>
</Target>
</Target> -->

<!-- Set PackageProjectUrl and PackageReleaseNotes to the package README.md and CHANGELOG.md respectively for DataPlane Libraries -->
<Target Name="SetPackageProjectUrlandReleaseNotes" BeforeTargets="GenerateNuspec" DependsOnTargets="InitializeSourceControlInformationFromSourceControlManager" Condition="'$(IsShippingLibrary)' == 'true' and '$(SourceRevisionId)' != ''">
Expand Down Expand Up @@ -98,6 +99,15 @@

</ItemGroup>

<!-- Remove packages built into the .NET 6+ runtime -->
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net8.0'">
m-redding marked this conversation as resolved.
Show resolved Hide resolved
<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 = (AsymmetricAlgorithm)signer.SigningCertificates[0].GetRSAPublicKey() ?? signer.SigningCertificates[0].GetDSAPublicKey();
#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 = (AsymmetricAlgorithm)signingKey.Certificate.GetRSAPrivateKey() ?? signingKey.Certificate.GetDSAPrivateKey();
#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 = (AsymmetricAlgorithm)certificate.GetRSAPublicKey() ?? certificate.GetDSAPrivateKey();
#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 = (AsymmetricAlgorithm)certificate.GetRSAPublicKey() ?? certificate.GetDSAPublicKey();
#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 = ((AsymmetricAlgorithm)certificate.GetRSAPublicKey() ?? certificate.GetDSAPublicKey()).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 @@ -56,11 +56,12 @@ internal bool TryGetAndRemoveEvent(Func<CallAutomationEventBase, bool> predicate
// Try remove the item - if successful, return it as keyValuePair
if (matchingKvp.Key != default && _eventBacklog.TryRemove(matchingKvp.Key, out var returnedValue))
{
matchingEvent = new KeyValuePair<string, CallAutomationEventBase>(matchingEvent.Key, returnedValue.Item1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing the following:

error CS0269: Use of unassigned out parameter 'matchingEvent' [C:\...\azure-sdk-for-net\sdk\communication\Azure.Communication.CallAutomation\src\Azure.Communication.CallAutomation.csproj::TargetFramework=net8.0]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change the behavior of the method? Do we know what the intended behavior is?

Copy link
Member Author

@m-redding m-redding Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an error not a warning, so the current code cannot stay as-is. Someone from the communication team should take a look to make sure this is the intended behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an obvious mistake, as the parameter has not been initialized at this point. My suspicion is that the conditional never/rarely matches so this code never actually executes in any kind of test.

Maddy's fix looks to be the obvious one to correct the behavior based on the method name. We removed matchingKvp.Key and we want to return it.

Let's reach out to the ACS team and ask them to sign-off. If they don't respond in a week, here's how I'd like to proceed with this:

  • We move forward with the change, since it's a hard compile error.
  • We open an issue to document.
  • We create a new test that always fails with a message that references the issue.
  • We reach out to the ACS team and let them know this is what we did, so that they're not blocking the repository.

That will block CI for any future changes/releases.

Thing we need to check first: can this library ever get randomly pulled into the Core test suite? If so, we need to make sure that doesn't happen since we're adding a consistent failure.

matchingEvent = new KeyValuePair<string, CallAutomationEventBase>(matchingKvp.Key, returnedValue.Item1);
return true;
}
else
{
matchingEvent = default;
return false;
}
}
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