This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.
ScriptDOM is a powerful .NET library for code parsing, generating an abstract syntax tree (AST) that can be leveraged to apply code formatting, detect antipatterns, and more. We are thrilled to announce that the source code for ScriptDOM has been released into open source under the MIT license and is available on GitHub. In addition, ScriptDOM is now distributed by Microsoft as a standalone NuGet package.
ScriptDOM capabilities
Several use cases for ScriptDOM are mentioned in Arvind Shyamsundar’s excellent review article, “Programmatically parsing Transact SQL (T-SQL) with the ScriptDom parser”. Each use of ScriptDOM is rooted in the construction of an abstract syntax tree that can be accessed by subsequent interactions. The following example code reads text from a file and checks it for T-SQL syntax errors:
The many classes within the ScriptDOM namespace are constructed around the TSqlParser class. As new syntax is added to Azure SQL and SQL Server, it is aligned with the appropriate derived class, such as TSql160Parser.
Community involvement
We believe that ScriptDOM has the potential to grow beyond the valuable library it is today with a nearly limitless future powered by developers. By open sourcing ScriptDOM, we hope to enable more people to build innovative tools and projects on top of this library. You are encouraged to check out the source code on the GitHub repository, contribute to the project, and share your feedback with us.
Here are some community projects and blog posts to inspire you:
https://github.com/arvindshmicrosoft/SQLScriptDomSamples
https://github.com/davebally/TSQL-Smells
https://www.sqlservercentral.com/stairways/stairway-to-scriptdom
https://the.agilesql.club/2015/11/how-to-get-started-with-the-scriptdom/
Speaking of community - we'd also like to thank Duncan Smart, who graciously transferred the NuGet.org package name Microsoft.SqlServer.TransactSql.ScriptDom to the team.
We look forward to engaging with you both in the ScriptDOM repository and in the DacFx discussions.