I press Ctrl+Shift+L in JetBrains Rider, which opens a dialog window. I select Whole Solution, and it starts cleaning up the code. However, I want it to stop transforming this:
public Task<PackageTest?> GetByPackageAndTestIdAsync(Guid packageId, Guid testId) =>
_context.PackageTests.FirstOrDefaultAsync(p => p.TestId == testId && p.PackageId == packageId);
into this:
public Task<PackageTest?> GetByPackageAndTestIdAsync(Guid packageId, Guid testId)
{
return _context.PackageTests.FirstOrDefaultAsync(p => p.TestId == testId && p.PackageId == packageId);
}
>Solution :
Try turning off "Apply code body style (expression body vs block body)".
- Open Code(menu) -> Reformat and CleanUp
- From the ‘Select Profile’ select the profile that you’re using
- Click on the edit icon at the top of the left frame.
- On the ‘Code Cleanup Options’ Window turn off ‘Apply code body style (expression body vs block body)’ in the ‘Apply syntax styles’ -> ‘C#’.