The Microsoft SQL ScriptDOM library provides parsing and analysis capabilities for management and development of TSQL Scripts.
$ dotnet add package Microsoft.SqlServer.TransactSql.ScriptDomSQL Script DOM is a .NET library that provides formatting and parsing capabilities to analyze SQL Scripts. It can be used by Powershell and C#.
Script DOM is used by DacFX and as an standalone library for client applications.
Open issues at SQL Script DOM github