Skip to content

Add Name parameter to UserPasskeyInfo constructor#65815

Open
BloodShop wants to merge 2 commits intodotnet:mainfrom
BloodShop:fix/passkey-name-ctor
Open

Add Name parameter to UserPasskeyInfo constructor#65815
BloodShop wants to merge 2 commits intodotnet:mainfrom
BloodShop:fix/passkey-name-ctor

Conversation

@BloodShop
Copy link

Summary

UserPasskeyInfo exposes a Name property but the constructor doesn't accept it — it's the only property left out. Callers have to fall back to an object initializer:

var passkey = new UserPasskeyInfo(credentialId, publicKey, ...)
{
    Name = "My Security Key"  // why can't this go in the constructor?
};

This adds a constructor overload so Name can be set inline with everything else.

What changed

UserPasskeyInfo gets a second constructor with an additional trailing string? name parameter. The original constructor delegates to it with name: null, so nothing breaks — existing call sites compile and behave exactly as before.

UserPasskeyInfo.cs

  • New constructor overload: ..., byte[] clientDataJson, string? name)
  • Original constructor chains into it via : this(..., name: null)

PublicAPI.Unshipped.txt

  • New API entry for the overloaded constructor

UserPasskeyInfoTest.cs (new file)

  • Verifies the new constructor sets all properties including Name
  • Verifies passing null leaves Name unset
  • Verifies the original constructor still works and leaves Name null

Usage

// Before (still works)
var passkey = new UserPasskeyInfo(credentialId, publicKey, createdAt,
    signCount, transports, isUserVerified, isBackupEligible, isBackedUp,
    attestationObject, clientDataJson)
{
    Name = "My Security Key"
};

// After (also works now)
var passkey = new UserPasskeyInfo(credentialId, publicKey, createdAt,
    signCount, transports, isUserVerified, isBackupEligible, isBackedUp,
    attestationObject, clientDataJson, name: "My Security Key");

Breaking changes

None. The existing constructor signature is untouched and remains in PublicAPI.Shipped.txt. The new overload is additive only.

Fixes #65774

UserPasskeyInfo exposes a Name property but the constructor doesn't
accept it, forcing callers to use an object initializer to set it.
Every other property is covered by the constructor, so the omission
feels unintentional.

This adds a new constructor overload that accepts an optional
'string? name' parameter. The existing constructor is preserved
(it delegates to the new one with name: null) so there's no binary
or source breaking change.

Changes:
- New constructor overload on UserPasskeyInfo with trailing 'name'
  parameter
- Existing constructor chains into the new one
- PublicAPI.Unshipped.txt updated
- Unit tests for both constructors

Fixes dotnet#65774
@github-actions github-actions bot added the area-identity Includes: Identity and providers label Mar 17, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 17, 2026
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@BloodShop. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@BloodShop
Copy link
Author

@dotnet-policy-service agree

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

Labels

area-identity Includes: Identity and providers community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UserPasskeyInfo should have Name in the constructor

2 participants