Skip to content

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

Merged
333fred merged 3 commits intodotnet:mainfrom
333fred:prefer-string-in-9
Aug 3, 2021
Merged

Only prefer interpolated string handler conversions in C# 10#55380
333fred merged 3 commits intodotnet:mainfrom
333fred:prefer-string-in-9

Conversation

@333fred
Copy link
Copy Markdown
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
@ghost ghost added the Area-Compilers label Aug 3, 2021
IL_002b: ldloc.0
IL_002c: call ""void C.M(CustomHandler)""
IL_0031: ret
IL_0000: call ""void CultureInfoNormalizer.Normalize()""
Copy link
Copy Markdown
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 force-pushed the prefer-string-in-9 branch from 774729a to 3e4dbde Compare 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

Development

Successfully merging this pull request may close these issues.

Updating program to .NET 6 Preview 7 SDK causes warnings about interpolated string handlers in previously working code

4 participants