Open Tragetaschen opened 2 years ago
Version Used: 17.2.0 Preview 2.0
Steps to Reproduce:
public class C { private struct S { } public string M() { S s; var a = "" + s; // "Inline temporary variable" for a return a; } }
Run "Inline temporary variable" for a.
a
Expected Behavior:
public class C { private struct S { } public string M() { S s; // "Inline temporary variable" for a return "" + s; } }
Actual Behavior:
public class C { private struct S { } public string M() { S s; // "Inline temporary variable" for a return (string?)("" + s); } }
The refactoring introduces a cast to (string?) even though neither a nor the return type were ever nullable.
(string?)
On a related note: Is the comment trivia expected to stay where it is and not move to the return line?
return
I think this is because var has is inferred as nullable type. A fix for this may reuse helpers in #58866
var
We would take a targeted community fix here.
Version Used: 17.2.0 Preview 2.0
Steps to Reproduce:
Run "Inline temporary variable" for
a
.Expected Behavior:
Actual Behavior:
The refactoring introduces a cast to
(string?)
even though neithera
nor the return type were ever nullable.On a related note: Is the comment trivia expected to stay where it is and not move to the
return
line?