-
Notifications
You must be signed in to change notification settings - Fork 11
Make CredentialDescription AOT-compatible via C# 14 extension properties (v11.0.0) #238
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
Merged
bgavrilMS
merged 20 commits into
main
from
copilot/make-credentialdescription-aot-compatible
Feb 3, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
08ccb50
Initial plan
Copilot 2966569
Initial commit - planning AOT compatibility changes for CredentialDes…
Copilot 112e717
Implement AOT-compatible CredentialDescription for .NET 10+ with exte…
Copilot 6b47d7d
Add changelog entry for AOT compatibility changes
Copilot 882b8f4
Add comment explaining LangVersion preview requirement
Copilot 72db344
Fix comment typos: CachedID -> Cached Id
Copilot 8a8d3c8
Improve extension class documentation clarity
Copilot 0e80eac
Add detailed remarks about C# 15 extension property syntax
Copilot 60731d7
Enhance LangVersion preview documentation with migration plan
Copilot 3b6093a
Address PR feedback: revert NuGet.config, use C# 14 instead of preview
Copilot a55edf7
Bump version to 11.0.0 for binary breaking change
Copilot 12510c2
Tweaks
jmprieur a08ce07
Add Microsoft.Identity.Abstractions.AotTests project for .NET 10 AOT …
Copilot 82cae95
Improve the AoT test
jmprieur 64ea9b7
Add AOT test execution to CI pipeline
Copilot 106848b
Update changelog with C# 14 requirement and troubleshooting guidance
Copilot 6758c57
Change internal methods to protected internal for derived class access
Copilot 25e322d
Address review feedback: simplify copy constructor, add CA1024 pragma…
Copilot 1d19c66
Clarify extension properties are .NET 10+ by design choice, not langu…
Copilot 0054e3f
Refine documentation: C# 14 available on all TFMs, used on .NET 10+ b…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Microsoft.Identity.Abstractions/ApplicationOptions/CredentialDescriptionExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #if NET10_0_OR_GREATER | ||
| using System.Security.Cryptography.X509Certificates; | ||
|
|
||
| namespace Microsoft.Identity.Abstractions | ||
| { | ||
| /// <summary> | ||
| /// Provides extension properties for <see cref="CredentialDescription"/> instances (.NET 10+ only). | ||
| /// These extension properties provide property-style access to Certificate and CachedValue | ||
| /// while keeping them hidden from AOT/NativeAOT configuration binders. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This uses C# 14 extension property syntax. While C# 14 extension properties as a language feature | ||
| /// are available on any target framework, for this library they are only exposed on .NET 10+ by design | ||
| /// to avoid binary breaking changes on older frameworks. | ||
| /// The extension block defines properties that appear as instance properties on CredentialDescription | ||
| /// but are not part of the type's public API surface visible to reflection-based tools like configuration binders. | ||
| /// </remarks> | ||
| public static class CredentialDescriptionExtensions | ||
| { | ||
| #pragma warning disable CA1034 // Do not nest type - this is intentional C# 14 extension block syntax | ||
| // C# 14 extension block syntax - defines extension properties on CredentialDescription | ||
| extension(CredentialDescription credential) | ||
| { | ||
| /// <summary> | ||
| /// When <see cref="CredentialDescription.SourceType"/> is <see cref="CredentialSource.Certificate"/>, you will use this property to provide the certificate yourself. | ||
| /// When <see cref="CredentialDescription.SourceType"/> is <see cref="CredentialSource.Base64Encoded"/> or <see cref="CredentialSource.KeyVault"/> | ||
| /// or <see cref="CredentialSource.Path"/> or <see cref="CredentialSource.StoreWithDistinguishedName"/> or <see cref="CredentialSource.StoreWithThumbprint"/> | ||
| /// after the certificate is retrieved by a <see cref="ICredentialsLoader"/>, it will be stored in this property and also in the <b>CachedValue</b> property. | ||
| /// </summary> | ||
| public X509Certificate2? Certificate | ||
| { | ||
| get => credential.GetCertificateInternal(); | ||
| set => credential.SetCertificateInternal(value); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// When the credential is retrieved by a <see cref="ICredentialsLoader"/>, it will be stored in this property, where you can retrieve it. If the credential is a certificate, | ||
| /// it will also be stored in the <b>Certificate</b> property. | ||
| /// </summary> | ||
| public object? CachedValue | ||
| { | ||
| get => credential.GetCachedValueInternal(); | ||
| set => credential.SetCachedValueInternal(value); | ||
| } | ||
| } | ||
| #pragma warning restore CA1034 | ||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.