Skip to content

Type-forward IsExternalInit on modern .NET. #423

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

Closed
wants to merge 1 commit into from

Conversation

teo-tsirpanis
Copy link

Fixes compatibility between the .NET Standard 2.0 and modern .NET assemblies.

See Sergio0694/PolySharp#98 (comment) for more details.

@jsquire
Copy link
Collaborator

jsquire commented Jun 27, 2025

@KrzysztofCwalina, @christothes, @stephentoub: Would appreciate thoughts on this one.

@stephentoub
Copy link
Contributor

@teo-tsirpanis, why? We don't do that in other places, e.g. System.Text.Json has an internal IsExternalInit when built for netstandard2.0 or net462 but doesn't include one when targeting net8.0, net9.0, or net10.0.

@teo-tsirpanis
Copy link
Author

System.Text.Json actually does type-forward IsExternalInit on modern frameworks. It needs that because it has one public property with an init; accessor. The OpenAI library does not have a public init; property yet, but once it gets one, it will require type-forwarding IsExternalInit. We can do this now or later.

@stephentoub
Copy link
Contributor

stephentoub commented Jun 28, 2025

actually does type-forward IsExternalInit

Thanks, I missed we added that.

In what situation do we expect the netstandard asset to be resolved when an app targets net core?

@stephentoub
Copy link
Contributor

stephentoub commented Jun 28, 2025

Ah, I guess it's the opposite. A netstandard lib is built against this one, and will bake in that reference. Then that netstandard only library gets used on core. OK, this makes sense.

But I'd do it later only if / when it's actually needed; otherwise it's leaking implementation detail.

@jsquire
Copy link
Collaborator

jsquire commented Jun 28, 2025

Thank you for your contribution, @teo-tsirpanis, and for your interest in improving the OpenAI developer experience.

The OpenAI library does not have a public init; property yet, but once it gets one, it will require type-forwarding IsExternalInit. We can do this now or later.

We avoid init properties as part of the API surface because of these types of corner cases in netstandard2.0 fallbacks. If that's the scenario that is motivating this change, I don't expect that it will be needed.

@jsquire
Copy link
Collaborator

jsquire commented Jul 10, 2025

Thank you, @teo-tsirpanis, for your contribution and interest in improving the OpenAI developer experience. After discussion between the maintainers and confirming that we have no plans to make use of init properties due to the netstandard2.0 compatibility concerns, I'm going to close this out.

@jsquire jsquire closed this Jul 10, 2025
@teo-tsirpanis teo-tsirpanis deleted the is-external-init branch July 10, 2025 00:09
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