microsoft / microsoft/typespec

[http-client-csharp] Resolve GA date-time name ownership for projected properties

Open
#11,783 1 comment 1 reaction 0 assignees View on GitHub
bug emitter:client:csharp
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

## Description

The GA date-time name preservation added by #11773 determines whether a historical contract name is already claimed by checking sibling properties from `inputProperty.EnclosingType`. That is correct for ordinary model properties, but the input enclosing model is not necessarily the `TypeProvider` that emits a projected or flattened property.

This can produce two incorrect ownership decisions:

1. A sibling exists on the source wire model but is not projected onto the target provider. The unprojected sibling can incorrectly block preservation of an otherwise available GA name.
2. Properties from different source wire models are projected onto the same target provider. They cannot see each other through their respective input models and can both claim the same contract name.

Conceptually:

```text
Wire model A: startTime -> projected onto ResourceData
Wire model A: startOn -> not projected
GA ResourceData: StartOn
Expected projected name: StartOn
```

and:

```text
Wire model A: startTime -> projected onto ResourceData
Wire model B: startOn -> projected onto ResourceData
GA ResourceData: StartOn
Expected names: StartsOn, StartOn
```

## Why this is deferred

`PropertyProvider` has the source `InputProperty` and target `TypeProvider` during construction, but the target provider's complete property collection is not available yet. Reading `enclosingType.Properties` at that point would recursively invoke property construction.

A prototype in #11773 split candidate discovery from provider-level reconciliation after `BuildProperties()`. Although it handled synthetic projected cases, it introduced lifecycle complexity because providers, constructors, serialization providers, and downstream visitors can materialize or transform property identities at different stages. The actual management-plane flattening implementation also lives in `Azure.Generator.Management`, so MTG-only synthetic coverage does not validate the real integration path.

## Expected behavior

Historical date-time names should be checked against members actually emitted on the target provider, not all siblings from the source wire model. Resolution must happen before constructor parameters and serialization providers consume the final property names.

## Suggested direction

- Add integration coverage using the management-plane `FlattenPropertyVisitor`/`FlattenedPropertyProvider` path.
- Decide whether ownership should be handled by:
- a provider-level name reservation/reconciliation phase with a clearly defined lifecycle; or
- a narrow API allowing a projecting generator to provide the actual projected property set or historical-name candidates.
- Preserve ordinary non-projected behavior from #11773.

## Regression coverage

Cover both:

1. An unprojected source sibling does not block a GA name on the target provider.
2. Properties projected from different input models onto one target provider cannot both claim the same GA name.

Follow-up to #11773.

- by copilot

Contributor guide

Open the contributing guide

Research direction

Start with the GA date-time preservation logic from #11773, then trace PropertyProvider and TypeProvider construction through BuildProperties(). Read the management-plane FlattenPropertyVisitor and FlattenedPropertyProvider path and add integration coverage for both projected-property ownership cases. Done means target-provider names match the expected outcomes without consuming final names too late for constructor parameters or serialization providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.