March 29th, 2010

ASP.NET/HTML Spell Checker 2.3 is available for Visual Studio 2010

ASP.NET/HTML Spell Checker 2.3 for Visual Studio 2010 has been posted on Visual Studio Gallery (also accessible from Visual Studio Start page in ‘Extending Visual Studio’ section). Direct link: http://visualstudiogallery.msdn.microsoft.com/en-us/0db4814c-255e-4cc6-a2c2-a428de7f8949

What’s new in version 2.3:

  • VS 2010 version installs from gallery as Visual Studio Extension package (VSIX)
  • In VS 2010 suggestion list is invoked via right button click (instead of double click as in earlier versions).
  • Fixed bug:
    • Fixing misspelled word it may also remove punctuation that immediately follows it.

For additional information please refer to readme.htm included in the download – you can find it in the extension directory, typically 

C:UsersUSER_NAMEAppDataLocalMicrosoftVisualStudio10.0ExpExtensionsMicrosoftHTMLASP.NET Spell Checker for VS 20102.3

 as well as to the earlier blog post on version 2.2.

To run spell check on all files in solution you can use the following macro

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module SpellChecker
    Private _outputWindow As OutputWindowPane

    Public Sub SpellCheckSolution()
        _outputWindow = GetOutputWindowPane(“HTML Spell Checker”)
        _outputWindow.Clear()
        _outputWindow.OutputString(“Running spell check on files in the solution…” + vbCrLf)

        For Each project As Project In DTE.Solution.Projects
            ProcessProjectItemCollection(project.ProjectItems)
        Next

        _outputWindow.OutputString(“Spell check complete.” + vbCrLf)
    End Sub

    Private Sub ProcessProjectItemCollection(ByVal projItemsCollection As ProjectItems)

        For Each pi As ProjectItem In projItemsCollection

            Dim childrenCount = 0
            If Not pi.ProjectItems Is Nothing Then
                childrenCount = pi.ProjectItems.Count
            End If

            If childrenCount = 0 Then
                If pi.Kind = Constants.vsProjectItemKindPhysicalFile And IsKnownFileType(pi.Name) Then
                    Try
                        Dim window As Window
                        Dim opened As Boolean = False

                        If pi.Document Is Nothing Then
                            window = pi.Open(Constants.vsViewKindTextView)
                            ‘opened = True
                        Else
                            window = pi.Document.ActiveWindow
                            If (window Is Nothing) Then
                                window = pi.Open(Constants.vsViewKindTextView)
                            End If
                        End If

                        window.Visible = True
                        window.Activate()
                        _outputWindow.OutputString(pi.Name + vbCrLf)

                        DTE.ExecuteCommand(“Tools.SpellChecker”)

                        ‘If Not window.Caption.Contains(“*”) And opened = True Then
                        ‘window.Close()
                        ‘End If

                    Catch ex As Exception
                        _outputWindow.OutputString(“Could not check ” + pi.Name + “, exception ” + ex.Message + vbCrLf)
                    End Try
                End If
            Else
                ProcessProjectItemCollection(pi.ProjectItems)
            End If
        Next
    End Sub

    Private Function GetOutputWindowPane(ByVal Name As String) As OutputWindowPane
        Dim window As Window
        Dim outputWindow As OutputWindow
        Dim outputWindowPane As OutputWindowPane

        window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
        window.Visible = True
        outputWindow = window.Object
        Try
            outputWindowPane = outputWindow.OutputWindowPanes.Item(Name)
        Catch e As System.Exception
            outputWindowPane = outputWindow.OutputWindowPanes.Add(Name)
        End Try
        outputWindowPane.Activate()
        Return outputWindowPane
    End Function

    Private Function IsKnownFileType(ByVal name As String) As Boolean
        Dim knownExtensions() As String = New String() {“.cs”, “.vb”, “htm”, “.html”, “.css”, “.inc”, “.js”, “.vbs”, _
                                                       “.aspx”, “.asp”, “.ascx”, “.ashx”, “.asmx”, _
                                                       “.cpp”, “.h”, “.hpp”, “.hxx”}

        For Each ext As String In knownExtensions
            If name.EndsWith(ext) Then
                Return True
            End If
        Next

        Return False
    End Function
End Module

Thanks

Mikhail Arkhipov

0 comments

Discussion are closed.