This issue has been moved from a ticket on Developer Community.
[EN] The IDE0046 true configuration seems to not be taken in account when code refactoring (Ctrl+K/E).
Here is a code sample :
namespace Namespace1
{
public class Class1
{
public override bool Equals(object obj)
{
if (obj is Class1 class1)
return Equals(class1);
return false;
}
public bool Equals(Class1 class1) => true; //actual comparison goes here
public override int GetHashCode() => base. GetHashCode();
}
}
And the associated .editorconfig file (French environment) :
[*.cs]
# IDE0046: Convertir en expression conditionnelle
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
# IDE0011: Ajouter des accolades
csharp_prefer_braces = when_multiline:silent
# IDE0003: Supprimer une qualification
dotnet_style_qualification_for_method = false:silent
# IDE0022: Utiliser un corps de bloc pour les méthodes
csharp_style_expression_bodied_methods = true:silent
What I was waiting for is what the editor itself manually suggests ("Convertir en expression conditionnelle") :
return obj is Class1 class1 ? Equals(class1) : false;, that is then gracefully refactored (Ctrl+K/E) as
namespace Namespace1
{
public class Class1
{
public override bool Equals(object obj) => obj is Class1 class1 ? Equals(class1) : false;
public bool Equals(Class1 class1) => true; //actual comparison goes here
public override int GetHashCode() => base. GetHashCode();
}
}
Do you need more informations ?
[FR] La configuration de IDE0046 true semble ignorée lors de l'exécution du nettoyage de code. Voir cas d'usage ci-avant. Je reste à disposition si vous avez besoin d'informations complémentaires.
Original Comments
Visual Studio Feedback System on 3/9/2020, 08:24 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Visual Studio Feedback System on 3/12/2020, 08:48 PM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.
Original Solutions
(no solutions)
This issue has been moved from a ticket on Developer Community.
[EN] The IDE0046
trueconfiguration seems to not be taken in account when code refactoring (Ctrl+K/E).Here is a code sample :
And the associated
.editorconfigfile (French environment) :What I was waiting for is what the editor itself manually suggests ("Convertir en expression conditionnelle") :
return obj is Class1 class1 ? Equals(class1) : false;, that is then gracefully refactored (Ctrl+K/E) asDo you need more informations ?
[FR] La configuration de IDE0046
truesemble ignorée lors de l'exécution du nettoyage de code. Voir cas d'usage ci-avant. Je reste à disposition si vous avez besoin d'informations complémentaires.Original Comments
Visual Studio Feedback System on 3/9/2020, 08:24 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Visual Studio Feedback System on 3/12/2020, 08:48 PM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.
Original Solutions
(no solutions)