In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?
Set a breakpoint in your code, and start debugging by pressing F5 or selecting Debug > Start Debugging. When paused at the breakpoint, hover over any variable in the current scope. A data tip appears, showing the name and current value of the variable.
Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.
Add a T Value and a bool IsInitialized property to it, and a constructor that takes a T parameter, assigns it to Value , and sets IsInitialized to true.
Find all References is your friend.
From MSDN
The Find object allows you to search for and replace text in places of the environment that support such operations, such as the Code editor.
It is intended primarily for macro recording purposes. The editor's macro recording mechanism uses Find rather than TextSelection.FindPattern so that you can discover the global find functionality, and because it generally is more useful than using the TextSelection Object for such operations as Find-in-files.
If the search operation is asynchronous, such as Find All, then the FindDone Event occurs when the operation completes.
Sub ActionExample()
   Dim objFind As Find = objTextDoc.DTE.Find
   ' Set the find options.
   objFind.Action = vsFindAction.vsFindActionFindAll
   objFind.Backwards = False
   objFind.FilesOfType = "*.vb"
   objFind.FindWhat = "<Variable>"
   objFind.KeepModifiedDocumentsOpen = False
   objFind.MatchCase = True
   objFind.MatchInHiddenText = True
   objFind.MatchWholeWord = True
   objFind.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
   objFind.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
   objFind.SearchPath = "c:\<Your>\<Project>\<Path>"
   objFind.SearchSubfolders = False
   objFind.Target = vsFindTarget.vsFindTargetCurrentDocument
   ' Perform the Find operation.
   objFind.Execute()
End Sub
<System.ContextStaticAttribute()> _
Public WithEvents FindEvents As EnvDTE.FindEvents
Public Sub FindEvents_FindDone(ByVal Result As EnvDTE.vsFindResult, _
                               ByVal Cancelled As Boolean) _
                               Handles FindEvents.FindDone
   Select Case Result 
        case vsFindResultFound
             'Found!
        case else
             'Not Found
   Ens select
End Sub
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With