Rider C# comment at start of line

Answered

Is there any way to change Rider generation of Commented Code lines?

When I use Ctrl + / to comment selected lines of code the result is to have the comment's // at the start of the line.

I can turn this off in Typescript but how do I prevent it in C#?

Thanks

Brian

 

4 comments
Comment actions Permalink

Hi Brian,

Could you please clarify what should be done on ctrl + / instead?



Kind regards, 

Sofia.

0
Comment actions Permalink

My code block looks like this:

var attendees = await attendeeRepository.GetAllAsync(
a => a.Id == request.AttendeeId &&
( a.IsBookingCanceled == false || !a.IsBookingCanceled.IsDefined()));

if (attendees.Count < 1)
{
this.logger.Warning("Attempt to download Calendar for non-existent or cancelled attendee with correlation id: {AttendeeId}, Ignoring", request.AttendeeId);
return new FileStreamResult(Stream.Null, "text/calendar");
}

var attendee = attendees[0];

When I use the keyboard combination I get the following:

               var attendees = await attendeeRepository.GetAllAsync(
a => a.Id == request.AttendeeId &&
( a.IsBookingCanceled == false || !a.IsBookingCanceled.IsDefined()));

// if (attendees.Count < 1)
// {
// this.logger.Warning("Attempt to download Calendar for non-existent or cancelled attendee with correlation id: {AttendeeId}, Ignoring", request.AttendeeId);
// return new FileStreamResult(Stream.Null, "text/calendar");
// }

i.e. the comment starts at column 1 

what I want is the following

var attendees = await attendeeRepository.GetAllAsync(
a => a.Id == request.AttendeeId &&
( a.IsBookingCanceled == false || !a.IsBookingCanceled.IsDefined()));

// if (attendees.Count < 1)
// {
// this.logger.Warning("Attempt to download Calendar for non-existent or cancelled attendee with correlation id: {AttendeeId}, Ignoring", request.AttendeeId);
// return new FileStreamResult(Stream.Null, "text/calendar");
// }

var attendee = attendees[0];

i.e. the comment is indented and aligned with the current code block and only single space after the double-slash characters
0
Comment actions Permalink

Hi Brian,

Thank you for the detailed explanation.

To get the desired formatting, turn off the option named "Don't indent comments started at first column" in "Preferences | Editor | Code Style | C#" -> "Tabs, Indents, Alignment".

 

Let me know if you need assistance.

 

Sofia.

0
Comment actions Permalink

Great, that does it, thanks. 

0

Please sign in to leave a comment.