Solved

How can i remove all <summary> tags and the comments inside them?

Posted on 2010-08-24
6
405 Views
Last Modified: 2013-11-27
I want to remove all the <summary> tags including the content inside them in a class file.

So if i want to remove all the following with one operation

<summary>
blablabla
</summary>

How can i do this?
0
Comment
Question by:Norush
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33509682
Why would you like to do that ?

I don't know any way then to do it manually, or create another program, that reads the classfile, and removes the tags with a regexp.

Example: http://dotnetperls.com/remove-html-tags
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33509746
can u post a sample class file with summary tag for testing?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33509927
here's a vbs that does that.

change CLASSES_FILES_FOLDER  to the folder where the classes files with the summaries you wish to remove.
it will detect c# files and vb.net files and remove all summaries from functions, properties and classes.
const CLASSES_FILES_FOLDER = "c:\temp\files"

set fso = createobject("scripting.filesystemobject")
Set objFolder = fso.GetFolder(CLASSES_FILES_FOLDER)
For Each objFile In objFolder.Files
	token = ""
	select case fso.GetExtensionName(objFile)
		case "cs": token = "///"
		case "vb": token = "'''"
	end select
	
	if token <> "" then
		RemoveSummary objFile.Path, token
	end if
 Next

 
 sub RemoveSummary(filename, token)
	
	set objSrcFile = fso.OpenTextFile(filename, 1)
	data = ""
	match = false
	Do Until objSrcFile.AtEndOfStream
		strLine = objSrcFile.Readline
		if InStr(strLine, token & " <summary>") > 0  then
			match = true
		else 
			if match = true then
				if InStr(strLine, token) = 0 then
					match = false
					data = data & strLine & vbNewLine
				end if
			else
				data = data & strLine & vbNewLine
			end if
		end if
	Loop
	
	objSrcFile.Close
	
	set objOutFile = fso.CreateTextFile(filename & "_", 2)
	objOutFile.Write data
	objOutFile.Close
 end sub

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 33510126
made  a mistake in the script, here's the working one:
const CLASSES_FILES_FOLDER = "c:\temp\files"

set fso = createobject("scripting.filesystemobject")
Set objFolder = fso.GetFolder(CLASSES_FILES_FOLDER)
For Each objFile In objFolder.Files
	token = ""
	select case fso.GetExtensionName(objFile)
		case "cs": token = "///"
		case "vb": token = "'''"
	end select
	
	if token <> "" then
		RemoveSummary objFile.Path, token
	end if
 Next

 
 sub RemoveSummary(filename, token)
	
	set objSrcFile = fso.OpenTextFile(filename, 1)
	data = ""
	match = false
	Do Until objSrcFile.AtEndOfStream
		strLine = objSrcFile.Readline
		if InStr(strLine, token & " <summary>") > 0  then
			match = true
		else 
			if match = true then
				if InStr(strLine, token) = 0 then
					match = false
					data = data & strLine & vbNewLine
				end if
			else
				data = data & strLine & vbNewLine
			end if
		end if
	Loop
	
	objSrcFile.Close
	
	set objOutFile = fso.CreateTextFile(filename, 2)
	objOutFile.Write data
	objOutFile.Close
 end sub

Open in new window

0
 
LVL 7

Author Closing Comment

by:Norush
ID: 33511575
Thanks alot !
0
 
LVL 7

Author Comment

by:Norush
ID: 33524068
Could have wrote that on my own actualy :)

Did manage to rebuild this into a Visual Studio Maco and attach it to a custom toolbar.

Now its integrated in my VS :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now