Introduce explicit downcast refactoring if a variable requires a cast to compile#41371
Introduce explicit downcast refactoring if a variable requires a cast to compile#41371y87feng merged 98 commits intodotnet:masterfrom
Conversation
src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests_FixAllTests.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
lots of safety concerns. but a great start!
|
Hi @y87feng ! Thanks for the contribution. Overall this is a great start. The primary things we'll need here are good docs in teh code explaining why what it is doing is correct (as it's not self evident), as well as a lot of beefing up the safety of hte feature. i.e. the code currently makes a ton of assumptions about the results it may get back from certain calls. This is not safe and may absolutely crash in existin code scenarios (or future changes as the compiler/langauge moves forward). I'm happy to help out with more information on this if you need it! |
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
A lot nicer! Needs some comments in code to help with things, and some small refactoring. But overall very close!
…icitCastCodeFixProvider.cs Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/CodeFixes/AddExplicitCast/AddExplicitCastCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
Looks fantastic! 📦
…icitCastCodeFixProvider.cs Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
…icitCastCodeFixProvider.cs Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
|
Congratulations! |
Implemented code fix for error code: CS0266, CS1503
Issue link: #40967