[CSHARP-360] Proposal: replace #region directives with comments Created: 29/Nov/11  Updated: 02/Apr/15  Resolved: 13/Dec/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.3.1
Fix Version/s: 1.4

Type: Task Priority: Minor - P4
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-359 Proposal: change code formatting to V... Closed

 Description   

The code base currently uses #region directives (as recommended by Microsoft) to mark regions of the file (constructors, properties, methods, etc...).

The disadvantage of using #region directives is that when you open a file in Visual Studio the regions are collapsed (when using default Visual Studio settings). This is annoying, because one must immediately expand all the regions to look at or work on the file.

The proposal is to replace:

#region some comment
... contents of the region
#endregion

with

// some comment
... contents of the region

The files would still be organized like they are now (grouping similar members like properties or methods together) but just wouldn't have #regions anymore.

The only thing lost is the ability to collapse regions, but I personally never find collapsing the regions helpful.

See the related JIRA issue about code formatting as well.

No decision will be made on this proposal for a few weeks to allow time for comments.



 Comments   
Comment by Robert Stam [ 13/Dec/11 ]

Code base now contains no #regions.

Comment by Justin Dearing [ 05/Dec/11 ]

I actually like regions being auto-collapsed. Then again, I'm really weird in general.I'm not going to cry either way, but I vote against this.

Comment by karl seguin [ 30/Nov/11 ]

I agree with Craig. I think distinction between member types is made-up. And while I agree fields shoudl stick with fields, and methods with methods, I'm skeptical that the lack of comments will cause any problems. The only time I've been thankful for these types of markers is when a class is bloated and should probably be refactored.

Comment by Robert Stam [ 29/Nov/11 ]

The comments would just be "constructors", "properties", "methods", etc...

Arguments in favor of keeping:

  • a visual marker where one region ends and another begins
  • a reminder that new members should be placed with other like members
  • something to search for when navigating the file (probably not common)
Comment by Craig Wilson [ 29/Nov/11 ]

I'd probably not leave the //some comment in there unless it has some special meaning other than Properties or Methods or etc...

Generated at Wed Feb 07 21:36:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.