Skip to content

Add support for JsonStringEnumMemberName and X509CertificateLoader for .net10#651

Merged
abergs merged 17 commits into
passwordless-lib:mainfrom
vpetrusevici:update-to-.net10
Apr 14, 2026
Merged

Add support for JsonStringEnumMemberName and X509CertificateLoader for .net10#651
abergs merged 17 commits into
passwordless-lib:mainfrom
vpetrusevici:update-to-.net10

Conversation

@vpetrusevici

Copy link
Copy Markdown
Contributor

Summary
Adds compatibility updates for .NET 10+, including conditional attributes, improved type handling, and support for JsonStringEnumMemberName.

Details

Notes
To enable this support and prevent runtime issues, usage of X509CertificateLoader was also introduced.
Some minor changes in tests too.

…improved type handling, and JsonStringEnumMemberName attribute.
@vpetrusevici

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="maib"

@abergs

abergs commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

I think this is in the right direction, however we don't solve for the COSE serialisation as mentioned in this comment: #645 (comment)

But that doesn't necessarily need to block this PR and could be done in a follow up PR. Not sure if everyone impacted by this problem is also impacted by that problem.

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

In our case the only problem was enum string value, so i hope it will fix at least this one

Comment thread nuget.config Outdated

@abergs abergs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for working on this, much appreciated. Left some comments and pushed a small cleanup.

Comment thread Tests/Fido2.Tests/Attestation/Tpm.cs Outdated
@abergs

abergs commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

@iamcarbon You know your way around jsonmember serialisation better than I do. Any other comments here?

I'm thinking we only drop .net8 in november, so this would be a nice stop gap solution for people already on .net 10.

@vpetrusevici

vpetrusevici commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, did i broke something in tests?
Looks like i found where

@iamcarbon

Copy link
Copy Markdown
Contributor

Consider using an internal Polyfill for JsonStringEnumMemberName to avoid churn (which we can delete when removing the .NET9 target). If we only use this in Models, we could also just delete EnumMember then.

@iamcarbon

Copy link
Copy Markdown
Contributor

Consider also dedupping the logic for certification loading into a helper.

@iamcarbon

Copy link
Copy Markdown
Contributor

The unrelated changes in Tpm should also be proposed in a separate PR, so this remains scoped to supporting .NET10

@vpetrusevici

vpetrusevici commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

looks like all comments are resolved

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

fixed last tests. i hope

@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.61%. Comparing base (40b302c) to head (7b9b1b2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #651      +/-   ##
==========================================
- Coverage   78.62%   78.61%   -0.01%     
==========================================
  Files          98       98              
  Lines        2545     2544       -1     
  Branches      423      425       +2     
==========================================
- Hits         2001     2000       -1     
  Misses        434      434              
  Partials      110      110              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abergs

abergs commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

@vpetrusevici Seems MacOS tests are still failing.

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

Sorry. I don't see anything in the changes yet that could affect this. It's probably some kind of incompatibility with .NET 10. Could you help me please? @abergs

@abergs

abergs commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

@vpetrusevici Alright so I've done some analysis and I can see what's going wrong.

In your PR, you change how the apple tests load certificates in Apple.cs. You change from using a constructor to using the helper function. The helper function catches exceptions and doesn't rethrow the original, instead wraps everything in an new Exception, which is why the expected type of the exception is now different.

I think perhaps we should remove the try/catch from the wrapper as it doesn't add much value? I think (I haven't verified) that all callers are internal. We would maybe in some situation expose the CryptographicException to callers, but I don't think that is necessarily bad.

edit:

If we want to be a bit more surgical (but it adds complexity) we catch and rethrow CryptographicException. Not sure if there are any other exceptions that could be thrown though.

@vpetrusevici

vpetrusevici commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I also think that we should see the real exception for such cases
+1 to remove the catch

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

Removed try catch. fixed one test for this exception

@abergs

abergs commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

@vpetrusevici Unfortunately tests still seem to be failing on both mac and linux.

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

Ok, i see. I added unnecessary assert, it has different exception on each platform...

@vpetrusevici

Copy link
Copy Markdown
Contributor Author

@abergs try again please

@abergs

abergs commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

All checks look good, let's merge this :) Thank you for all the follow up.

@abergs
abergs merged commit 20501e0 into passwordless-lib:main Apr 14, 2026
9 checks passed
@abergs

abergs commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

I've released 5.0.0-preview.1 from main with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants