Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio add-on to tag code segments?

I wonder if there exists any add-on for VS that can substitute/tag some lines of code with a descriptive text of my choice ?

Ideally a function like the one below :

bool CreateReportFiles(LPCTSTR fn_neighbours, ULONG nItems, ULONG* items)

{

// Read from file

CFile cf_neighbours;

if (!cf_neighbours.Open(fn_neighbours, CFile::modeRead))

  return false;

cf.Read(items, sizeof(ULONG) * nItems);

cf.Close();




// Create reports

DoReport_1(items, nItems);

DoReport_2(items, nItems);

DoReport_3(items, nItems);

FinalizeReports();

}

...would look similar to this :

bool CreateReportFiles(LPCTSTR fn_neighbours, ULONG nItems, ULONG* items)

{

± Read from file

± Do the reports

}

The ± signs would expand / collapse the substituted lines.
Other workarounds also considered !
Thanks for your help !

like image 724
sevaxx Avatar asked Jun 08 '26 18:06

sevaxx


1 Answers

The region functionality does pretty much precisely what you describe, and is built into Visual Studio.

The following will compress as you described:

bool CreateReportFiles(LPCTSTR fn_neighbours, ULONG nItems, ULONG* items)

{

#pragma region ReadFile
// Read from file

CFile cf_neighbours;

if (!cf_neighbours.Open(fn_neighbours, CFile::modeRead))

  return false;

cf.Read(items, sizeof(ULONG) * nItems);

cf.Close();

#pragma endregion ReadFile

#pragma region CreateReports

// Create reports

DoReport_1(items, nItems);

DoReport_2(items, nItems);

DoReport_3(items, nItems);

FinalizeReports();

#pragma endregion CreateReports
}
like image 58
Ryan Brunner Avatar answered Jun 11 '26 07:06

Ryan Brunner