Skip to content

Named union picker omits Value for nullable custom value type #404

Description

@HavenDV

Reproduction

Anthropic regeneration PR tryAGI/Anthropic#295 fails its newly restored PR build in run 36287263480 (attempt 2):

Generated/Anthropic.Models.BetaManagedAgentsModelParams.g.cs(45,89): error CS0266: Cannot implicitly convert type 'Anthropic.BetaManagedAgentsModel?' to 'Anthropic.BetaManagedAgentsModel'.

PickBetaManagedAgentsModel() returns the nullable value-type property with ! rather than extracting .Value. The same regenerated PR also removes .Value from the matching System.Text.Json converter. The generator's HasNullableValueVariant(TypeData) in Sources.Models.AnyOf.cs requires IsAnyOfLike, IsEnum, a built-in primitive, or a global::System.* name even when TypeData.IsValueType is true; this custom enum/value type misses those branches.

Expected

Generated named-union pickers and serializers compile for every nullable value-type variant. Add a focused generator regression test with a custom value-type variant, then regenerate Anthropic and validate build and trim. Do not hand-edit Generated/.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions