Skip to content
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

Only prefer interpolated string handler conversions in C# 10 #55380

Merged
merged 3 commits into from
Aug 3, 2021

Conversation

333fred
Copy link
Member

@333fred 333fred commented Aug 3, 2021

Closes #55345. Note that we will still know about the conversion, meaning that if a library introduces an interpolated string handler overload and has another overload with a conversion that is not "better" than any other conversion, such as an overload between Span<char> and CustomHandler, that code will be considered ambiguous and not compile. I think that is fine though, as 99% of these cases will be overloads between string and CustomHandler, not Span<char> and CustomHandler.

Test plan: #51499

Closes dotnet#55345. Note that we will still know about the conversion, meaning that if a library introduces an interpolated string handler overload and has another overload with a conversion that is not "better" than any other conversion, such as an overload between `Span<char>` and `CustomHandler`, that code will be considered ambiguous and not compile. I think that is fine though, as 99% of these cases will be overloads between `string` and `CustomHandler`, not `Span<char>` and `CustomHandler`.
@333fred 333fred requested a review from a team as a code owner August 3, 2021 17:33
IL_002b: ldloc.0
IL_002c: call ""void C.M(CustomHandler)""
IL_0031: ret
IL_0000: call ""void CultureInfoNormalizer.Normalize()""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only change in the IL here is this line. Otherwise, C# 10 remains the same.

@333fred 333fred enabled auto-merge (squash) August 3, 2021 18:04
@333fred 333fred requested a review from a team as a code owner August 3, 2021 18:06
@333fred 333fred removed the request for review from a team August 3, 2021 18:07
@333fred 333fred merged commit 76bdda7 into dotnet:main Aug 3, 2021
@ghost ghost added this to the Next milestone Aug 3, 2021
@333fred 333fred deleted the prefer-string-in-9 branch August 3, 2021 20:19
@dibarbet dibarbet modified the milestones: Next, 17.0.P4 Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants