-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
TypeBinder.Deserialize<T> should have new() constraint #40718
Comments
Thank you for your feedback. We'll add this to the Azure.Core backlog for consideration. |
@AlexanderSher: Would you please take point for understanding the end-to-end scenario and making a recommendation on whether we should make this change? |
Adding @jsquire, @KrzysztofCwalina @tg-msft - do we allow this kind of source breaking change? |
Not outside of special circumstances such as security issues. If this feature would introduce breaking changes to the public API for stable packages, then this does not look like a change that we would make. Unless I'm overlooking something, the benefit of this change would be convenience (better runtime safety) - which would not outweigh the breaking change, in my opinion. |
I figured this was probably the case. In which case, I would propose making an "audit" of upstream APIs and check which ones do and do not declare new() themselves. (I wouldn't mind putting this together). Then maybe do some combination of the following?
|
I noticed that
And the
Given its small footprint, I think we should be able to at least do 1) and/or 4). |
azure-sdk-for-net/sdk/core/Azure.Core/src/Shared/TypeBinder.cs
Lines 131 to 143 in 07bb13a
This method should have a
new()
constraint, as it can only handle primitive types or types with a parameterless constructor. Propagating the resultingnew()
constraints s up the call chain (such as toAzure.Monitor.Query.LogsQueryClient.QueryWorkspaceAsync<T>
) would prevent runtime errors that could be caught at compile time instead.The text was updated successfully, but these errors were encountered: