Hello,
I have this code :
C#public int? GetId(string cnk, ArticleType articleType)
C#{
DomainObjects.Article article = this.articleDal
.ReadByCnk(cnk)
.SingleOrDefault(x => x.ArticleType == articleType.ToString());
if (article != null)
return article.Id;
return null;
}
When I format I get this mess :
C#public int? GetId(string cnk, ArticleType articleType)
{
DomainObjects.Article article = this.articleDal
.ReadByCnk(cnk)
.SingleOrDefault(x
=> x.ArticleType == articleType.ToString());
if(article != null)
return article.Id;
return null;
}
Hi Christian,
Thank you for providing the settings and code snippets.
I have reproduced the problem, we will try to fix it shortly. As a workaround, you can temporary disable two formatting options to avoid unexpected code formatting:
Also, could you please provide us with formatted code snippets which you would like to have after applying CodeRush formatting?
Probably, we can help you configure your CodeRush formatting options more precisely, for expected result code?
DomainObjects.Article article = this.articleDal .ReadByCnk(cnk) .SingleOrDefault(x => x.ArticleType == articleType.ToString());
but the the expression body is set to have something like this :
public string MyMethod() => "bla bla"
Christian, you are right; CodeRush has different settings for expression bodies and lambda expressions.
In my previous message I suggested disabling the "Chained Method Calls" and "Lambda Expression" options only as a temporary workaround.
For now, we have fixed the problem and prepared a special build with the fix for you.
Could you please enable "Chained Method Calls" and "Lambda Expression", install the build with a fix, try to reproduce the problem and notify as of your results?
Note: Christian, I amn't sure what result you want to have after formatting. Could you take the settings from the screenshot into account? Maybe it's exactly what you want to have as a result.