Solved

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

Posted on 2010-08-24
6
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

717 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