I have converted a VB6 project to VB.NET and am left with a large number of inline 'warning messages' such as "UPGRADE_WARNING: Couldn't resolve default property of object varJonSkeet" that I would like to get rid of. Is there a way to do this within Visual Studio 2008? Will it be easier to remove the warning messages with regex? I would prefer to do the removals one file at a time, but it isn't a dealbreaker.
Rewrite the project in VB.NET. Getting rid of the warnings might is only a means to get to the goal which (i presume) is a working program.
The best way to get rid of warnings is to address the suspicious code that the warnings complain about. That is, change the code such that it is no longer warning-worthy. Don't just seek to disable the generation of warnings altogether.
You'll need to provide more details about the specific warnings you're concerned about, and the accompanying code. But remember to search previous answers here first.
I see the warnings are actually text literally in your code, not messages issued in the compiler output. The way to get rid of those is to search for the keyword (UPGRADE_WARNING, I guess), consider whether the issue that it warns about has been addressed or is still a valid concern, fix the problem if there is one, and the delete that warning line. For example, does varJonSkeet
have a default property, and if not, does it need one? Should you use to a non-default property instead? (You're not really asking how to delete a line of text, are you?)
If you've already gone through the whole file and determined that none of the warnings are valid, there's a quick way of removing all the warning lines.
grep -v UPGRADE_WARNING input_file.vb > output_file.vb ren output_file.vb input_file.vb
If you don't already have grep
on your system, then you don't have a complete development environment yet. Go get a copy. The -v
option tells it to invert the search results, thus printing all lines that don't contain the search pattern. Those get written into the new file. Then replace the old file with the new one.
I believe he is saying that he wants to remove the inline comments from his code.
Fastest way is to perform a find in files for UPGRADE_WARNING: and remove them by hand.
Or,
You could create a new .Net program to iterate through each .vb file in your source directory and read them in using a StreamReader and then write them out 1 line at a time to the same file and as you go omit any lines containing UPGRADE_WARNING:.
If you do the second way you will be that much better for having done some more vb.net coding.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FileName As String = "c:\form1.vb"
Dim SourceFile As System.IO.FileInfo = New FileInfo(FileName)
Dim SourceTextStream As System.IO.TextReader = SourceFile.OpenText()
Dim SourceFileContent() As String = Split(SourceTextStream.ReadToEnd(), vbCrLf)
SourceTextStream.Close()
Dim CurrentSourceLine As String
Dim CurrentSourceLineNumber As Long
Dim DestStream As StreamWriter = New StreamWriter(FileName)
Dim LogStream As StreamWriter = New StreamWriter(FileName + ".log")
For Each CurrentSourceLine In SourceFileContent
CurrentSourceLineNumber += 1
If InStr(CurrentSourceLine, "UPGRADE_WARNING") = 0 Then
DestStream.WriteLine(CurrentSourceLine)
Else
' Write to Log File
LogStream.WriteLine("Line Skipped at number: " + CurrentSourceLineNumber.ToString())
End If
Next
DestStream.Close()
LogStream.Close()
End Sub