Skip to content

Improve LangVersion diagnostic for target typed conditional#54797

Merged
RikkiGibson merged 2 commits intodotnet:mainfrom
RikkiGibson:fix-cond-expr-diagnostic
Jul 14, 2021
Merged

Improve LangVersion diagnostic for target typed conditional#54797
RikkiGibson merged 2 commits intodotnet:mainfrom
RikkiGibson:fix-cond-expr-diagnostic

Conversation

@RikkiGibson
Copy link
Copy Markdown
Member

@RikkiGibson RikkiGibson commented Jul 13, 2021

Closes #54793

@adegeo @BillWagner let me know if you have any feedback about the wording of the diagnostic (see the changed tests for examples).

@RikkiGibson RikkiGibson requested review from a team as code owners July 13, 2021 20:37
@ghost ghost added the Area-Compilers label Jul 13, 2021
Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

I like the message @RikkiGibson It guides a developer to the potential fixes when they can upgrade, or must fix the code as is.

@RikkiGibson
Copy link
Copy Markdown
Member Author

Great, thanks!

@RikkiGibson RikkiGibson enabled auto-merge (squash) July 13, 2021 20:55
"CS8904", // error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2<T1, T2>.M1(T1)' unless language version 'preview' or greater is used. 'T1' is covariant.
"CS8912", // error CS8912: Inheriting from a record with a sealed 'Object.ToString' is not supported in C# {0}. Please use language version '{1}' or greater.
"CS8704", // error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater.
"CS8957", // error CS8957: Conditional expression is not valid in language version '8.0' because a common type was not found between 'int' and '<null>'. To use a target-typed conversion, upgrade to language version '9.0' or greater.
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 Jul 13, 2021

Choose a reason for hiding this comment

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

Consider adding a test for the codefix. Just saw it. Sorry!

@RikkiGibson RikkiGibson merged commit 99db879 into dotnet:main Jul 14, 2021
@ghost ghost added this to the Next milestone Jul 14, 2021
@RikkiGibson RikkiGibson deleted the fix-cond-expr-diagnostic branch July 14, 2021 00:06
@allisonchou allisonchou modified the milestones: Next, 17.0.P3 Jul 27, 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.

Suggestion to upgrade to C# 9 is hiding true error

6 participants