From b9105106319718d1dffb5ae3cca4482d892c518d Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Sat, 9 May 2020 21:52:15 -0700 Subject: [PATCH 1/9] Update to current DacFx + misc. cleanup (#1) --- .gitignore | 11 ++++ 1_BasicUsage/1_BasicUsage.csproj | 47 ++++++++++----- 1_BasicUsage/Program.cs | 32 ++++------ 1_BasicUsage/app.config | 3 + 1_BasicUsage/packages.config | 4 ++ 2_VisitorPattern/2_VisitorPattern.csproj | 54 +++++++++++------ 2_VisitorPattern/Program.cs | 41 +++++++------ 2_VisitorPattern/app.config | 3 + 2_VisitorPattern/packages.config | 4 ++ 2_VisitorPattern/solution.txt | 6 -- 3_ScriptTokens/3_ScriptTokens.csproj | 47 ++++++++++----- 3_ScriptTokens/Program.cs | 33 +++++------ 3_ScriptTokens/app.config | 3 + 3_ScriptTokens/packages.config | 4 ++ 4_TSQLValidation/4_TSQLValidation.csproj | 58 +++++++++++++------ 4_TSQLValidation/Form1.cs | 54 ++++++++--------- 4_TSQLValidation/Program.cs | 6 +- .../Properties/Resources.Designer.cs | 46 ++++++--------- .../Properties/Settings.Designer.cs | 24 ++++---- 4_TSQLValidation/app.config | 3 + 4_TSQLValidation/packages.config | 4 ++ 5_TSQLFormatter/5_TSQLFormatter.csproj | 49 +++++++++++----- 5_TSQLFormatter/Form1.cs | 40 +++++-------- 5_TSQLFormatter/Program.cs | 6 +- .../Properties/Resources.Designer.cs | 46 ++++++--------- .../Properties/Settings.Designer.cs | 24 ++++---- 5_TSQLFormatter/app.config | 3 + 5_TSQLFormatter/packages.config | 4 ++ 5_TSQLFormatter/solution.txt | 5 -- 6_TSQLVisualizer/6_TSQLVisualizer.csproj | 47 ++++++++++----- 6_TSQLVisualizer/Program.cs | 19 +++--- 6_TSQLVisualizer/app.config | 3 + 6_TSQLVisualizer/packages.config | 4 ++ LICENSE | 22 +++++++ README.md | 2 + ScriptDOMSamples.sln | 33 ++++++++++- 36 files changed, 472 insertions(+), 322 deletions(-) create mode 100644 1_BasicUsage/app.config create mode 100644 1_BasicUsage/packages.config create mode 100644 2_VisitorPattern/app.config create mode 100644 2_VisitorPattern/packages.config delete mode 100644 2_VisitorPattern/solution.txt create mode 100644 3_ScriptTokens/app.config create mode 100644 3_ScriptTokens/packages.config create mode 100644 4_TSQLValidation/app.config create mode 100644 4_TSQLValidation/packages.config create mode 100644 5_TSQLFormatter/app.config create mode 100644 5_TSQLFormatter/packages.config delete mode 100644 5_TSQLFormatter/solution.txt create mode 100644 6_TSQLVisualizer/app.config create mode 100644 6_TSQLVisualizer/packages.config create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 451ae56..2972a57 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,14 @@ /4_TSQLValidation/obj/x86/Debug /5_TSQLFormatter/obj/x86/Debug /6_TSQLVisualizer/obj/x86/Debug +/1_BasicUsage/obj/Debug +/2_VisitorPattern/bin/Debug +/2_VisitorPattern/obj/Debug +/3_ScriptTokens/obj/Debug +/4_TSQLValidation/bin/Debug +/4_TSQLValidation/obj/Debug/TempPE +/4_TSQLValidation/obj/Debug +/5_TSQLFormatter/obj/Debug +/6_TSQLVisualizer/bin/Debug +/6_TSQLVisualizer/obj/Debug +/packages diff --git a/1_BasicUsage/1_BasicUsage.csproj b/1_BasicUsage/1_BasicUsage.csproj index caa3585..ec7d982 100644 --- a/1_BasicUsage/1_BasicUsage.csproj +++ b/1_BasicUsage/1_BasicUsage.csproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -10,8 +10,9 @@ Properties BasicUsage BasicUsage - v4.0 - Client + v4.6.1 + + 512 @@ -23,6 +24,7 @@ DEBUG;TRACE prompt 4 + false x86 @@ -32,24 +34,43 @@ TRACE prompt 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false + + + bin\Release\ + TRACE + true + pdbonly + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false - - False - ..\..\..\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll - - - - - - - + + + + + \ No newline at end of file diff --git a/7_StatementLists/Form1.Designer.cs b/7_StatementLists/Form1.Designer.cs new file mode 100644 index 0000000..62f328b --- /dev/null +++ b/7_StatementLists/Form1.Designer.cs @@ -0,0 +1,75 @@ +namespace TSQLFormatter +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox1.Location = new System.Drawing.Point(12, 12); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(781, 384); + this.textBox1.TabIndex = 0; + this.textBox1.WordWrap = false; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(375, 413); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(51, 23); + this.button1.TabIndex = 1; + this.button1.Text = "GO!"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(805, 448); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.Name = "Form1"; + this.Text = "T-SQL validator"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + } +} + diff --git a/7_StatementLists/Form1.cs b/7_StatementLists/Form1.cs new file mode 100644 index 0000000..e8c1d47 --- /dev/null +++ b/7_StatementLists/Form1.cs @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ + +using Microsoft.SqlServer.TransactSql.ScriptDom; +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; + +namespace TSQLFormatter +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + using (var rdr = new StringReader(textBox1.Text)) + { + IList errors = null; + var parser = new TSql150Parser(true, SqlEngineType.All); + var tree = parser.Parse(rdr, out errors); + + foreach (ParseError err in errors) + { + Console.WriteLine(err.Message); + } + + var checker = new MyVisitor(); + + tree.Accept(checker); + + var scrGen = new Sql150ScriptGenerator(); + string formattedSQL = null; + scrGen.GenerateScript(tree, out formattedSQL); + + MessageBox.Show(formattedSQL); + } + } + } + + class MyVisitor : TSqlFragmentVisitor + { + internal bool containsOnlySelects = true; + + public override void Visit(TSqlFragment node) + { + // We use this to check for, and remove any SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED statements + // Also, as a proof of concept, the visitor also introduces a SET NOCOUNT ON statement as the first statement + // We do this for TSqlBatch, TSqlProcedure as samples. + // Other fragment types are potentially extensions of this sample. + CheckandRewrite(node); + base.Visit(node); + } + + private void CheckandRewrite(TSqlFragment node) + { + var finalList = new List(); + var toRemoveList = new List(); + + IList stmtList = null; + if (node is TSqlBatch) + { + stmtList = (node as TSqlBatch).Statements; + } + + if (node is ProcedureStatementBodyBase) + { + stmtList = (node as CreateProcedureStatement).StatementList.Statements; + } + + if (stmtList is null) + { + return; + } + + foreach (TSqlStatement stmt in stmtList) + { + if (stmt is SetTransactionIsolationLevelStatement) + { + if (IsolationLevel.ReadUncommitted == + (stmt as SetTransactionIsolationLevelStatement).Level) + { + toRemoveList.Add(stmt); + } + } + } + + // Add a SET NOCOUNT ON statement + finalList.Add(new PredicateSetStatement() + { + Options = SetOptions.NoCount, + IsOn = true + }); + + // Remove any unwanted (SET TRANSACTION ISOLATION READ UNCOMMITTED) statements + foreach (var stmtToRemove in toRemoveList) + { + stmtList.Remove(stmtToRemove); + } + + finalList.AddRange(stmtList); + + stmtList.Clear(); + foreach(var stmt in finalList) + { + stmtList.Add(stmt); + } + } + } +} diff --git a/7_StatementLists/Form1.resx b/7_StatementLists/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/7_StatementLists/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/7_StatementLists/Program.cs b/7_StatementLists/Program.cs new file mode 100644 index 0000000..70f2e8f --- /dev/null +++ b/7_StatementLists/Program.cs @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ + +using System; +using System.Windows.Forms; + +namespace TSQLFormatter +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/7_StatementLists/Properties/AssemblyInfo.cs b/7_StatementLists/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9095f36 --- /dev/null +++ b/7_StatementLists/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TSQLFormatter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TSQLFormatter")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ad18d6d1-7875-4cfc-9128-149418db16b4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/7_StatementLists/Properties/Resources.Designer.cs b/7_StatementLists/Properties/Resources.Designer.cs new file mode 100644 index 0000000..04e1170 --- /dev/null +++ b/7_StatementLists/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TSQLFormatter.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TSQLFormatter.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/7_StatementLists/Properties/Resources.resx b/7_StatementLists/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/7_StatementLists/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/7_StatementLists/Properties/Settings.Designer.cs b/7_StatementLists/Properties/Settings.Designer.cs new file mode 100644 index 0000000..efab29f --- /dev/null +++ b/7_StatementLists/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TSQLFormatter.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/7_StatementLists/Properties/Settings.settings b/7_StatementLists/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/7_StatementLists/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/7_StatementLists/app.config b/7_StatementLists/app.config new file mode 100644 index 0000000..3dbff35 --- /dev/null +++ b/7_StatementLists/app.config @@ -0,0 +1,3 @@ + + + diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config new file mode 100644 index 0000000..997b947 --- /dev/null +++ b/7_StatementLists/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ScriptDOMSamples.sln b/ScriptDOMSamples.sln index 3167d0d..996af72 100644 --- a/ScriptDOMSamples.sln +++ b/ScriptDOMSamples.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "5_TSQLFormatter", "5_TSQLFo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "6_TSQLVisualizer", "6_TSQLVisualizer\6_TSQLVisualizer.csproj", "{51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "7_StatementLists", "7_StatementLists\7_StatementLists.csproj", "{82E6E27C-2B4D-4D83-A797-18EBF1F721F2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,6 +73,14 @@ Global {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|Any CPU.Build.0 = Release|Any CPU {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x86.ActiveCfg = Release|x86 {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x86.Build.0 = Release|x86 + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x86.ActiveCfg = Debug|x86 + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x86.Build.0 = Debug|x86 + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|Any CPU.Build.0 = Release|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.ActiveCfg = Release|x86 + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 937dcfcd352edf83deae4f9dbf6b6514353e0230 Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Tue, 8 Mar 2022 11:52:54 -0800 Subject: [PATCH 3/9] Add basic CI (#2) --- build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 build.yml diff --git a/build.yml b/build.yml new file mode 100644 index 0000000..b160b2e --- /dev/null +++ b/build.yml @@ -0,0 +1,17 @@ +name: Build ScriptDomSamples +on: pull_request + +jobs: + build: + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2.3.5 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.3 + - name: Setup NuGet + uses: NuGet/setup-nuget@v1.0.5 + - name: Restore NuGet Packages + run: nuget restore ScriptDOMSamples.sln + - name: Build ScriptDOMSamples + run: msbuild ScriptDOMSamples.sln /p:Configuration=Release From ddb4bf85c906eca039b4fb9eb1dbebad30710b69 Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Tue, 8 Mar 2022 11:56:08 -0800 Subject: [PATCH 4/9] Add basic CI (#3) --- build.yml => .github/workflows/build.yml | 0 ScriptDOMSamples.sln | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) rename build.yml => .github/workflows/build.yml (100%) diff --git a/build.yml b/.github/workflows/build.yml similarity index 100% rename from build.yml rename to .github/workflows/build.yml diff --git a/ScriptDOMSamples.sln b/ScriptDOMSamples.sln index 996af72..fde199e 100644 --- a/ScriptDOMSamples.sln +++ b/ScriptDOMSamples.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30011.22 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "1_BasicUsage", "1_BasicUsage\1_BasicUsage.csproj", "{88301D6F-7C0B-4950-891D-999F991133A6}" EndProject @@ -17,6 +17,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "6_TSQLVisualizer", "6_TSQLV EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "7_StatementLists", "7_StatementLists\7_StatementLists.csproj", "{82E6E27C-2B4D-4D83-A797-18EBF1F721F2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A19B07A2-A103-4BC5-9705-F8C01FCE3C5D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{698BF626-CEC2-4FAF-80A3-40D515134A54}" + ProjectSection(SolutionItems) = preProject + build.yml = build.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -85,6 +92,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {698BF626-CEC2-4FAF-80A3-40D515134A54} = {A19B07A2-A103-4BC5-9705-F8C01FCE3C5D} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {939348C3-B244-4160-B9C0-66DFE32ED9B2} EndGlobalSection From 54b124735d602bdd097edbb6d9dfef4b79241b52 Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Tue, 8 Mar 2022 12:15:33 -0800 Subject: [PATCH 5/9] Upgrade to DacFx 160 and .NET Framework 4.8 (#4) --- 1_BasicUsage/1_BasicUsage.csproj | 6 +++--- 1_BasicUsage/packages.config | 2 +- 2_VisitorPattern/2_VisitorPattern.csproj | 6 +++--- 2_VisitorPattern/packages.config | 2 +- 3_ScriptTokens/3_ScriptTokens.csproj | 6 +++--- 3_ScriptTokens/packages.config | 2 +- 4_TSQLValidation/4_TSQLValidation.csproj | 6 +++--- 4_TSQLValidation/packages.config | 2 +- 5_TSQLFormatter/5_TSQLFormatter.csproj | 6 +++--- 5_TSQLFormatter/packages.config | 2 +- 6_TSQLVisualizer/6_TSQLVisualizer.csproj | 6 +++--- 6_TSQLVisualizer/packages.config | 2 +- 7_StatementLists/7_StatementLists.csproj | 21 +++------------------ 7_StatementLists/packages.config | 2 +- 14 files changed, 28 insertions(+), 43 deletions(-) diff --git a/1_BasicUsage/1_BasicUsage.csproj b/1_BasicUsage/1_BasicUsage.csproj index ec7d982..fddf709 100644 --- a/1_BasicUsage/1_BasicUsage.csproj +++ b/1_BasicUsage/1_BasicUsage.csproj @@ -10,7 +10,7 @@ Properties BasicUsage BasicUsage - v4.6.1 + v4.8 512 @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/1_BasicUsage/packages.config b/1_BasicUsage/packages.config index 5ad8014..d6eaf1d 100644 --- a/1_BasicUsage/packages.config +++ b/1_BasicUsage/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/2_VisitorPattern/2_VisitorPattern.csproj b/2_VisitorPattern/2_VisitorPattern.csproj index 0e1b9bf..82b0a38 100644 --- a/2_VisitorPattern/2_VisitorPattern.csproj +++ b/2_VisitorPattern/2_VisitorPattern.csproj @@ -10,7 +10,7 @@ Properties BasicUsage BasicUsage - v4.6.1 + v4.8 512 @@ -69,8 +69,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/2_VisitorPattern/packages.config b/2_VisitorPattern/packages.config index 5ad8014..d6eaf1d 100644 --- a/2_VisitorPattern/packages.config +++ b/2_VisitorPattern/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/3_ScriptTokens/3_ScriptTokens.csproj b/3_ScriptTokens/3_ScriptTokens.csproj index dd7c2cb..6fdbbe5 100644 --- a/3_ScriptTokens/3_ScriptTokens.csproj +++ b/3_ScriptTokens/3_ScriptTokens.csproj @@ -10,7 +10,7 @@ Properties BasicUsage BasicUsage - v4.6.1 + v4.8 512 @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/3_ScriptTokens/packages.config b/3_ScriptTokens/packages.config index 5ad8014..d6eaf1d 100644 --- a/3_ScriptTokens/packages.config +++ b/3_ScriptTokens/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/4_TSQLValidation/4_TSQLValidation.csproj b/4_TSQLValidation/4_TSQLValidation.csproj index 6bdc727..61859bc 100644 --- a/4_TSQLValidation/4_TSQLValidation.csproj +++ b/4_TSQLValidation/4_TSQLValidation.csproj @@ -10,7 +10,7 @@ Properties TSQLFormatter TSQLFormatter - v4.6.1 + v4.8 512 @@ -93,8 +93,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/4_TSQLValidation/packages.config b/4_TSQLValidation/packages.config index 5ad8014..d6eaf1d 100644 --- a/4_TSQLValidation/packages.config +++ b/4_TSQLValidation/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/5_TSQLFormatter/5_TSQLFormatter.csproj b/5_TSQLFormatter/5_TSQLFormatter.csproj index 1b810a7..9b33988 100644 --- a/5_TSQLFormatter/5_TSQLFormatter.csproj +++ b/5_TSQLFormatter/5_TSQLFormatter.csproj @@ -10,7 +10,7 @@ Properties TSQLFormatter TSQLFormatter - v4.6.1 + v4.8 512 @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/5_TSQLFormatter/packages.config b/5_TSQLFormatter/packages.config index 5ad8014..d6eaf1d 100644 --- a/5_TSQLFormatter/packages.config +++ b/5_TSQLFormatter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/6_TSQLVisualizer/6_TSQLVisualizer.csproj b/6_TSQLVisualizer/6_TSQLVisualizer.csproj index d4aaa87..e768a4a 100644 --- a/6_TSQLVisualizer/6_TSQLVisualizer.csproj +++ b/6_TSQLVisualizer/6_TSQLVisualizer.csproj @@ -10,7 +10,7 @@ Properties TSQLVisualizer TSQLVisualizer - v4.6.1 + v4.8 512 @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.150.4769.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/6_TSQLVisualizer/packages.config b/6_TSQLVisualizer/packages.config index 5ad8014..d6eaf1d 100644 --- a/6_TSQLVisualizer/packages.config +++ b/6_TSQLVisualizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/7_StatementLists/7_StatementLists.csproj b/7_StatementLists/7_StatementLists.csproj index bb076c4..e26d7a1 100644 --- a/7_StatementLists/7_StatementLists.csproj +++ b/7_StatementLists/7_StatementLists.csproj @@ -10,7 +10,7 @@ Properties TSQLFormatter TSQLFormatter - v4.6.1 + v4.8 512 @@ -93,23 +93,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.Data.Tools.Schema.Sql.dll - - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.Data.Tools.Utilities.dll - - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.SqlServer.Dac.dll - - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.SqlServer.Dac.Extensions.dll - - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll - - - ..\packages\Microsoft.SqlServer.DacFx.150.5282.3\lib\net46\Microsoft.SqlServer.Types.dll + + ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config index 997b947..d6eaf1d 100644 --- a/7_StatementLists/packages.config +++ b/7_StatementLists/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From fda94da7aa47f17d476dcbf573a5218f5893acfc Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Tue, 8 Mar 2022 12:26:04 -0800 Subject: [PATCH 6/9] Reference .NET Framework 4.8 throughout (#5) --- 1_BasicUsage/packages.config | 2 +- 2_VisitorPattern/packages.config | 2 +- 3_ScriptTokens/packages.config | 2 +- 4_TSQLValidation/packages.config | 2 +- 5_TSQLFormatter/packages.config | 2 +- 6_TSQLVisualizer/packages.config | 2 +- 7_StatementLists/packages.config | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/1_BasicUsage/packages.config b/1_BasicUsage/packages.config index d6eaf1d..358ce19 100644 --- a/1_BasicUsage/packages.config +++ b/1_BasicUsage/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/2_VisitorPattern/packages.config b/2_VisitorPattern/packages.config index d6eaf1d..358ce19 100644 --- a/2_VisitorPattern/packages.config +++ b/2_VisitorPattern/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/3_ScriptTokens/packages.config b/3_ScriptTokens/packages.config index d6eaf1d..358ce19 100644 --- a/3_ScriptTokens/packages.config +++ b/3_ScriptTokens/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/4_TSQLValidation/packages.config b/4_TSQLValidation/packages.config index d6eaf1d..358ce19 100644 --- a/4_TSQLValidation/packages.config +++ b/4_TSQLValidation/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/5_TSQLFormatter/packages.config b/5_TSQLFormatter/packages.config index d6eaf1d..358ce19 100644 --- a/5_TSQLFormatter/packages.config +++ b/5_TSQLFormatter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/6_TSQLVisualizer/packages.config b/6_TSQLVisualizer/packages.config index d6eaf1d..358ce19 100644 --- a/6_TSQLVisualizer/packages.config +++ b/6_TSQLVisualizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config index d6eaf1d..358ce19 100644 --- a/7_StatementLists/packages.config +++ b/7_StatementLists/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From 47923a16e5c84f92032abf9461d3b6fc05779aad Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Wed, 27 Jul 2022 20:48:15 -0700 Subject: [PATCH 7/9] Add T-SQL normalizer sample + bump DacFx (#6) --- 1_BasicUsage/1_BasicUsage.csproj | 2 +- 1_BasicUsage/packages.config | 2 +- 2_VisitorPattern/2_VisitorPattern.csproj | 2 +- 2_VisitorPattern/packages.config | 2 +- 3_ScriptTokens/3_ScriptTokens.csproj | 2 +- 3_ScriptTokens/packages.config | 2 +- 4_TSQLValidation/4_TSQLValidation.csproj | 2 +- 4_TSQLValidation/packages.config | 2 +- 5_TSQLFormatter/5_TSQLFormatter.csproj | 2 +- 5_TSQLFormatter/packages.config | 2 +- 6_TSQLVisualizer/6_TSQLVisualizer.csproj | 2 +- 6_TSQLVisualizer/packages.config | 2 +- 7_StatementLists/7_StatementLists.csproj | 2 +- 7_StatementLists/packages.config | 2 +- .../8_TSQLTextNormalizer.csproj | 66 ++++++ 8_TSQLTextNormalizer/App.config | 6 + 8_TSQLTextNormalizer/Program.cs | 98 ++++++++ .../Properties/AssemblyInfo.cs | 36 +++ 8_TSQLTextNormalizer/TSqlNormalizer.cs | 213 ++++++++++++++++++ 8_TSQLTextNormalizer/TSqlVisitor.cs | 90 ++++++++ 8_TSQLTextNormalizer/packages.config | 4 + ScriptDOMSamples.sln | 12 +- 22 files changed, 538 insertions(+), 15 deletions(-) create mode 100644 8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj create mode 100644 8_TSQLTextNormalizer/App.config create mode 100644 8_TSQLTextNormalizer/Program.cs create mode 100644 8_TSQLTextNormalizer/Properties/AssemblyInfo.cs create mode 100644 8_TSQLTextNormalizer/TSqlNormalizer.cs create mode 100644 8_TSQLTextNormalizer/TSqlVisitor.cs create mode 100644 8_TSQLTextNormalizer/packages.config diff --git a/1_BasicUsage/1_BasicUsage.csproj b/1_BasicUsage/1_BasicUsage.csproj index fddf709..f9a2049 100644 --- a/1_BasicUsage/1_BasicUsage.csproj +++ b/1_BasicUsage/1_BasicUsage.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/1_BasicUsage/packages.config b/1_BasicUsage/packages.config index 358ce19..ce088d0 100644 --- a/1_BasicUsage/packages.config +++ b/1_BasicUsage/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/2_VisitorPattern/2_VisitorPattern.csproj b/2_VisitorPattern/2_VisitorPattern.csproj index 82b0a38..13e55e3 100644 --- a/2_VisitorPattern/2_VisitorPattern.csproj +++ b/2_VisitorPattern/2_VisitorPattern.csproj @@ -70,7 +70,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/2_VisitorPattern/packages.config b/2_VisitorPattern/packages.config index 358ce19..ce088d0 100644 --- a/2_VisitorPattern/packages.config +++ b/2_VisitorPattern/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/3_ScriptTokens/3_ScriptTokens.csproj b/3_ScriptTokens/3_ScriptTokens.csproj index 6fdbbe5..989b17e 100644 --- a/3_ScriptTokens/3_ScriptTokens.csproj +++ b/3_ScriptTokens/3_ScriptTokens.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/3_ScriptTokens/packages.config b/3_ScriptTokens/packages.config index 358ce19..ce088d0 100644 --- a/3_ScriptTokens/packages.config +++ b/3_ScriptTokens/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/4_TSQLValidation/4_TSQLValidation.csproj b/4_TSQLValidation/4_TSQLValidation.csproj index 61859bc..c445883 100644 --- a/4_TSQLValidation/4_TSQLValidation.csproj +++ b/4_TSQLValidation/4_TSQLValidation.csproj @@ -94,7 +94,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/4_TSQLValidation/packages.config b/4_TSQLValidation/packages.config index 358ce19..ce088d0 100644 --- a/4_TSQLValidation/packages.config +++ b/4_TSQLValidation/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/5_TSQLFormatter/5_TSQLFormatter.csproj b/5_TSQLFormatter/5_TSQLFormatter.csproj index 9b33988..0e4aeb4 100644 --- a/5_TSQLFormatter/5_TSQLFormatter.csproj +++ b/5_TSQLFormatter/5_TSQLFormatter.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/5_TSQLFormatter/packages.config b/5_TSQLFormatter/packages.config index 358ce19..ce088d0 100644 --- a/5_TSQLFormatter/packages.config +++ b/5_TSQLFormatter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/6_TSQLVisualizer/6_TSQLVisualizer.csproj b/6_TSQLVisualizer/6_TSQLVisualizer.csproj index e768a4a..317bcbd 100644 --- a/6_TSQLVisualizer/6_TSQLVisualizer.csproj +++ b/6_TSQLVisualizer/6_TSQLVisualizer.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/6_TSQLVisualizer/packages.config b/6_TSQLVisualizer/packages.config index 358ce19..ce088d0 100644 --- a/6_TSQLVisualizer/packages.config +++ b/6_TSQLVisualizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/7_StatementLists/7_StatementLists.csproj b/7_StatementLists/7_StatementLists.csproj index e26d7a1..96192c5 100644 --- a/7_StatementLists/7_StatementLists.csproj +++ b/7_StatementLists/7_StatementLists.csproj @@ -94,7 +94,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.160.5400.1\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config index 358ce19..ce088d0 100644 --- a/7_StatementLists/packages.config +++ b/7_StatementLists/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj new file mode 100644 index 0000000..61ec2d8 --- /dev/null +++ b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7} + Exe + Properties + TSQLTextNormalizer + TSQLTextNormalizer + v4.8 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/8_TSQLTextNormalizer/App.config b/8_TSQLTextNormalizer/App.config new file mode 100644 index 0000000..4bfa005 --- /dev/null +++ b/8_TSQLTextNormalizer/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/8_TSQLTextNormalizer/Program.cs b/8_TSQLTextNormalizer/Program.cs new file mode 100644 index 0000000..bafec20 --- /dev/null +++ b/8_TSQLTextNormalizer/Program.cs @@ -0,0 +1,98 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ +// +// This example shows how to use the TransactSql.ScriptDom parser to 'normalize' batch text and retain only unique query patterns +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace TSQLTextNormalizer +{ + using System; + using System.IO; + + class Program + { + static void Main(string[] args) + { + // Parameters we expect: + // .SQL filename to normalize + // output filename + // compat level (80...160) + // whether to treat the batches as case sensitive (true / false) + + if (4 != args.Length) + { + WriteMessageAndExit("Usage: Normalize "); + } + + if (!File.Exists(args[0])) + { + WriteMessageAndExit("Input file was not found; exiting."); + } + + if (File.Exists(args[1])) + { + Console.Write("Output file already exists. Overwrite? Press Y or N."); + char decision = Console.ReadKey().KeyChar; + if (string.Equals(decision.ToString(), "n", StringComparison.CurrentCultureIgnoreCase)) + { + WriteMessageAndExit("You selected not to overwrite; exiting."); + } + } + + int compatLevel = 160; + if (!int.TryParse(args[2], out compatLevel)) + { + WriteMessageAndExit("Invalid value for compatibility level. Valid values range from 80 to 160."); + } + + Console.WriteLine(); + + using (var input = new FileStream(args[0], FileMode.Open)) + { + using (var output = new FileStream(args[1], FileMode.Create)) + { + bool caseSensitive = true; + bool.TryParse(args[3], out caseSensitive); + + Console.WriteLine(new TSqlNormalizer().Normalize(input, output, compatLevel, caseSensitive)); + Console.WriteLine("Done!"); + } + } + } + + private static void WriteMessageAndExit(string msg) + { + Console.WriteLine(msg); + Environment.Exit(1); + } + } +} diff --git a/8_TSQLTextNormalizer/Properties/AssemblyInfo.cs b/8_TSQLTextNormalizer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2ab8e00 --- /dev/null +++ b/8_TSQLTextNormalizer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TSQLTextNormalizer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TSQLTextNormalizer")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("15c5cd8a-d960-4f45-a6ad-b3b13f9719c5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/8_TSQLTextNormalizer/TSqlNormalizer.cs b/8_TSQLTextNormalizer/TSqlNormalizer.cs new file mode 100644 index 0000000..75b817d --- /dev/null +++ b/8_TSQLTextNormalizer/TSqlNormalizer.cs @@ -0,0 +1,213 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ +namespace TSQLTextNormalizer +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Security.Cryptography; + using System.Text; + using System.Threading.Tasks; + + using Microsoft.SqlServer.TransactSql.ScriptDom; + + internal class TSqlNormalizer + { + internal string Normalize(Stream input, Stream output, int compatLevel, bool caseSensitive) + { + string retVal = string.Empty; + + Dictionary normalizedBatches = new Dictionary(); + + TextReader rdr = new StreamReader(input); + + TSqlParser parser; + + SqlScriptGenerator scrgen = null; + + switch (compatLevel) + { + case 80: + { + scrgen = new Sql80ScriptGenerator(); + parser = new TSql80Parser(true); + break; + } + case 90: + { + scrgen = new Sql90ScriptGenerator(); + parser = new TSql90Parser(true); + break; + } + case 100: + { + scrgen = new Sql100ScriptGenerator(); + parser = new TSql100Parser(true); + break; + } + case 110: + { + scrgen = new Sql110ScriptGenerator(); + parser = new TSql110Parser(true); + break; + } + case 120: + { + scrgen = new Sql120ScriptGenerator(); + parser = new TSql120Parser(true); + break; + } + case 130: + { + scrgen = new Sql130ScriptGenerator(); + parser = new TSql130Parser(true); + break; + } + case 140: + { + scrgen = new Sql140ScriptGenerator(); + parser = new TSql140Parser(true); + break; + } + case 150: + { + scrgen = new Sql150ScriptGenerator(); + parser = new TSql150Parser(true); + break; + } + case 160: + { + scrgen = new Sql160ScriptGenerator(); + parser = new TSql160Parser(true); + break; + } + default: + { + return "Invalid compatibility level specified; exiting."; + } + } + + IList errs; + TSqlFragment frag = parser.Parse(rdr, out errs); + + StringBuilder sb = new StringBuilder(); + foreach (ParseError err in errs) + { + sb.AppendLine(err.Message + "@ line " + err.Line); + } + + retVal += sb.ToString(); + + Parallel.ForEach( + (frag as TSqlScript).Batches, + batch => + { + myvisitor visit = new myvisitor(); + + StringBuilder origscript = new StringBuilder(); + + for (int tokIdx = batch.FirstTokenIndex; tokIdx <= batch.LastTokenIndex; tokIdx++) + { + origscript.Append(batch.ScriptTokenStream[tokIdx].Text); + } + + batch.Accept(visit); + + string script; + + scrgen.GenerateScript(batch, out script); + + string hashValue; + + using (var hashProvider = new SHA1CryptoServiceProvider()) + { + if (caseSensitive) + { + hashValue = Convert.ToBase64String(hashProvider.ComputeHash(Encoding.Unicode.GetBytes(script))); + } + else + { + hashValue = Convert.ToBase64String(hashProvider.ComputeHash(Encoding.Unicode.GetBytes(script.ToLowerInvariant()))); + } + } + + lock (normalizedBatches) + { + if (normalizedBatches.ContainsKey(hashValue)) + { + normalizedBatches[hashValue].count++; + } + else + { + normalizedBatches.Add( + hashValue, + new Batch() { count = 1, normalizedText = script, sample = origscript.ToString() }); + } + } + }); + + // The normalized (tokenized) text is in the Batch.text member above. The below writes that out to a file + var p = from b in normalizedBatches.Keys select new { hash = b, count = normalizedBatches[b] }; + + StringBuilder sbfinal = new StringBuilder(); + + foreach (string key in normalizedBatches.Keys) + { + string final = string.Format( + "-- {0} times:\r\n{1}", + normalizedBatches[key].count, + normalizedBatches[key].normalizedText); + + sbfinal.AppendLine(final); + sbfinal.AppendLine("GO"); + sbfinal.AppendLine(); + } + + TextWriter wr = new StreamWriter(output); + wr.Write(sbfinal.ToString()); + wr.Flush(); + wr.Dispose(); + wr = null; + + return retVal; + } + } + + internal class Batch + { + public string normalizedText; + + public string sample; + + public int count; + } +} diff --git a/8_TSQLTextNormalizer/TSqlVisitor.cs b/8_TSQLTextNormalizer/TSqlVisitor.cs new file mode 100644 index 0000000..1a82b7a --- /dev/null +++ b/8_TSQLTextNormalizer/TSqlVisitor.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ +namespace TSQLTextNormalizer +{ + using Microsoft.SqlServer.TransactSql.ScriptDom; + + class myvisitor : TSqlFragmentVisitor + { + public override void ExplicitVisit(InPredicate node) + { + int numvalues = node.Values.Count; + if (numvalues > 1) + { + for (int i = numvalues - 1; i > 0; i--) + { + if (node.Values[i] is Literal) + { + node.Values.RemoveAt(i); + } + } + } + + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(NumericLiteral node) + { + node.Value = "0.1"; + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(MoneyLiteral node) + { + node.Value = "$1"; + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(BinaryLiteral node) + { + node.Value = "0xABCD"; + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(RealLiteral node) + { + node.Value = "0.5E-2"; + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(IntegerLiteral node) + { + node.Value = "0"; + base.ExplicitVisit(node); + } + + public override void ExplicitVisit(StringLiteral node) + { + node.Value = "foo"; + base.ExplicitVisit(node); + } + } +} diff --git a/8_TSQLTextNormalizer/packages.config b/8_TSQLTextNormalizer/packages.config new file mode 100644 index 0000000..ce088d0 --- /dev/null +++ b/8_TSQLTextNormalizer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ScriptDOMSamples.sln b/ScriptDOMSamples.sln index fde199e..61be54e 100644 --- a/ScriptDOMSamples.sln +++ b/ScriptDOMSamples.sln @@ -21,9 +21,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A19B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{698BF626-CEC2-4FAF-80A3-40D515134A54}" ProjectSection(SolutionItems) = preProject - build.yml = build.yml + .github\workflows\build.yml = .github\workflows\build.yml EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "8_TSQLTextNormalizer", "8_TSQLTextNormalizer\8_TSQLTextNormalizer.csproj", "{D131443D-20C2-40F2-9D8B-6DA0EBE763B7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -88,6 +90,14 @@ Global {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|Any CPU.Build.0 = Release|Any CPU {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.ActiveCfg = Release|x86 {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.Build.0 = Release|x86 + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x86.ActiveCfg = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x86.Build.0 = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|Any CPU.Build.0 = Release|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x86.ActiveCfg = Release|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From ac473fa906a393f7f7a4a9431c8db4fcf9005f90 Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Mon, 30 Jan 2023 12:40:27 -0800 Subject: [PATCH 8/9] Add script token stream rewrite sample + Nuget updates (#8) --- 1_BasicUsage/1_BasicUsage.csproj | 4 +- 1_BasicUsage/Program.cs | 6 +- 1_BasicUsage/packages.config | 2 +- 2_VisitorPattern/2_VisitorPattern.csproj | 4 +- 2_VisitorPattern/Program.cs | 6 +- 2_VisitorPattern/packages.config | 2 +- 3_ScriptTokens/3_ScriptTokens.csproj | 4 +- 3_ScriptTokens/Program.cs | 6 +- 3_ScriptTokens/packages.config | 2 +- 4_TSQLValidation/4_TSQLValidation.csproj | 4 +- 4_TSQLValidation/Form1.Designer.cs | 2 +- 4_TSQLValidation/Form1.cs | 4 +- 4_TSQLValidation/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- 4_TSQLValidation/packages.config | 2 +- 5_TSQLFormatter/5_TSQLFormatter.csproj | 4 +- 5_TSQLFormatter/Form1.Designer.cs | 2 +- 5_TSQLFormatter/Form1.cs | 4 +- 5_TSQLFormatter/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- 5_TSQLFormatter/packages.config | 2 +- 6_TSQLVisualizer/6_TSQLVisualizer.csproj | 4 +- 6_TSQLVisualizer/Program.cs | 6 +- 6_TSQLVisualizer/packages.config | 2 +- 7_StatementLists/7_StatementLists.csproj | 4 +- 7_StatementLists/Form1.Designer.cs | 2 +- 7_StatementLists/Form1.cs | 4 +- 7_StatementLists/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- 7_StatementLists/packages.config | 2 +- .../8_TSQLTextNormalizer.csproj | 4 +- 8_TSQLTextNormalizer/Program.cs | 2 +- 8_TSQLTextNormalizer/TSqlNormalizer.cs | 4 +- 8_TSQLTextNormalizer/TSqlVisitor.cs | 2 +- 8_TSQLTextNormalizer/packages.config | 2 +- 9_TSQLRewrite/9_TSQLRewrite.csproj | 64 +++++++++++ 9_TSQLRewrite/App.config | 6 + 9_TSQLRewrite/Program.cs | 105 ++++++++++++++++++ 9_TSQLRewrite/Properties/AssemblyInfo.cs | 36 ++++++ 9_TSQLRewrite/packages.config | 4 + SampleProc.sql | 3 +- ScriptDOMSamples.sln | 48 ++++++++ 45 files changed, 323 insertions(+), 59 deletions(-) create mode 100644 9_TSQLRewrite/9_TSQLRewrite.csproj create mode 100644 9_TSQLRewrite/App.config create mode 100644 9_TSQLRewrite/Program.cs create mode 100644 9_TSQLRewrite/Properties/AssemblyInfo.cs create mode 100644 9_TSQLRewrite/packages.config diff --git a/1_BasicUsage/1_BasicUsage.csproj b/1_BasicUsage/1_BasicUsage.csproj index f9a2049..8435d41 100644 --- a/1_BasicUsage/1_BasicUsage.csproj +++ b/1_BasicUsage/1_BasicUsage.csproj @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/1_BasicUsage/Program.cs b/1_BasicUsage/Program.cs index befacd9..337f0f8 100644 --- a/1_BasicUsage/Program.cs +++ b/1_BasicUsage/Program.cs @@ -34,18 +34,18 @@ using System.Collections.Generic; using System.IO; -namespace BasicUsage +namespace SQLScriptDomSamples { class Program { static void Main(string[] args) { - using (var rdr = new StreamReader(@"c:\ScriptDom\sampleproc.sql")) + using (var rdr = new StreamReader(@"..\..\..\sampleproc.sql")) { IList errors = null; // pass the reader to the scriptdom - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/1_BasicUsage/packages.config b/1_BasicUsage/packages.config index ce088d0..1da61fb 100644 --- a/1_BasicUsage/packages.config +++ b/1_BasicUsage/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/2_VisitorPattern/2_VisitorPattern.csproj b/2_VisitorPattern/2_VisitorPattern.csproj index 13e55e3..2f7d1db 100644 --- a/2_VisitorPattern/2_VisitorPattern.csproj +++ b/2_VisitorPattern/2_VisitorPattern.csproj @@ -69,8 +69,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/2_VisitorPattern/Program.cs b/2_VisitorPattern/Program.cs index ec11fd2..12959be 100644 --- a/2_VisitorPattern/Program.cs +++ b/2_VisitorPattern/Program.cs @@ -34,16 +34,16 @@ using System.Collections.Generic; using System.IO; -namespace BasicUsage +namespace SQLScriptDomSamples { class Program { static void Main(string[] args) { - using (var rdr = new StreamReader(@"c:\ScriptDom\sampleproc.sql")) + using (var rdr = new StreamReader(@"..\..\..\sampleproc.sql")) { IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/2_VisitorPattern/packages.config b/2_VisitorPattern/packages.config index ce088d0..1da61fb 100644 --- a/2_VisitorPattern/packages.config +++ b/2_VisitorPattern/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/3_ScriptTokens/3_ScriptTokens.csproj b/3_ScriptTokens/3_ScriptTokens.csproj index 989b17e..fae0e26 100644 --- a/3_ScriptTokens/3_ScriptTokens.csproj +++ b/3_ScriptTokens/3_ScriptTokens.csproj @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/3_ScriptTokens/Program.cs b/3_ScriptTokens/Program.cs index 5e1818d..442d8ec 100644 --- a/3_ScriptTokens/Program.cs +++ b/3_ScriptTokens/Program.cs @@ -34,16 +34,16 @@ using System.Collections.Generic; using System.IO; -namespace BasicUsage +namespace SQLScriptDomSamples { class Program { static void Main(string[] args) { - using (var rdr = new StreamReader(@"c:\ScriptDom\sampleproc.sql")) + using (var rdr = new StreamReader(@"..\..\..\sampleproc.sql")) { IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/3_ScriptTokens/packages.config b/3_ScriptTokens/packages.config index ce088d0..1da61fb 100644 --- a/3_ScriptTokens/packages.config +++ b/3_ScriptTokens/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/4_TSQLValidation/4_TSQLValidation.csproj b/4_TSQLValidation/4_TSQLValidation.csproj index c445883..f357d21 100644 --- a/4_TSQLValidation/4_TSQLValidation.csproj +++ b/4_TSQLValidation/4_TSQLValidation.csproj @@ -93,8 +93,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/4_TSQLValidation/Form1.Designer.cs b/4_TSQLValidation/Form1.Designer.cs index 62f328b..53ec118 100644 --- a/4_TSQLValidation/Form1.Designer.cs +++ b/4_TSQLValidation/Form1.Designer.cs @@ -1,4 +1,4 @@ -namespace TSQLFormatter +namespace SQLScriptDomSamples { partial class Form1 { diff --git a/4_TSQLValidation/Form1.cs b/4_TSQLValidation/Form1.cs index dd7c1fe..732af8d 100644 --- a/4_TSQLValidation/Form1.cs +++ b/4_TSQLValidation/Form1.cs @@ -35,7 +35,7 @@ using System.IO; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { public partial class Form1 : Form { @@ -49,7 +49,7 @@ private void button1_Click(object sender, EventArgs e) using (var rdr = new StringReader(textBox1.Text)) { IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/4_TSQLValidation/Program.cs b/4_TSQLValidation/Program.cs index 70f2e8f..3f688bf 100644 --- a/4_TSQLValidation/Program.cs +++ b/4_TSQLValidation/Program.cs @@ -32,7 +32,7 @@ using System; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { static class Program { diff --git a/4_TSQLValidation/Properties/Resources.Designer.cs b/4_TSQLValidation/Properties/Resources.Designer.cs index 04e1170..43d490c 100644 --- a/4_TSQLValidation/Properties/Resources.Designer.cs +++ b/4_TSQLValidation/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { using System; diff --git a/4_TSQLValidation/Properties/Settings.Designer.cs b/4_TSQLValidation/Properties/Settings.Designer.cs index efab29f..a4f99f6 100644 --- a/4_TSQLValidation/Properties/Settings.Designer.cs +++ b/4_TSQLValidation/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/4_TSQLValidation/packages.config b/4_TSQLValidation/packages.config index ce088d0..1da61fb 100644 --- a/4_TSQLValidation/packages.config +++ b/4_TSQLValidation/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/5_TSQLFormatter/5_TSQLFormatter.csproj b/5_TSQLFormatter/5_TSQLFormatter.csproj index 0e4aeb4..3e90e08 100644 --- a/5_TSQLFormatter/5_TSQLFormatter.csproj +++ b/5_TSQLFormatter/5_TSQLFormatter.csproj @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/5_TSQLFormatter/Form1.Designer.cs b/5_TSQLFormatter/Form1.Designer.cs index 3ecd12e..94a734a 100644 --- a/5_TSQLFormatter/Form1.Designer.cs +++ b/5_TSQLFormatter/Form1.Designer.cs @@ -1,4 +1,4 @@ -namespace TSQLFormatter +namespace SQLScriptDomSamples { partial class Form1 { diff --git a/5_TSQLFormatter/Form1.cs b/5_TSQLFormatter/Form1.cs index 09c56c6..166216a 100644 --- a/5_TSQLFormatter/Form1.cs +++ b/5_TSQLFormatter/Form1.cs @@ -35,7 +35,7 @@ using System.IO; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { public partial class Form1 : Form { @@ -49,7 +49,7 @@ private void button1_Click(object sender, EventArgs e) using (var rdr = new StringReader(textBox1.Text)) { IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/5_TSQLFormatter/Program.cs b/5_TSQLFormatter/Program.cs index 70f2e8f..3f688bf 100644 --- a/5_TSQLFormatter/Program.cs +++ b/5_TSQLFormatter/Program.cs @@ -32,7 +32,7 @@ using System; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { static class Program { diff --git a/5_TSQLFormatter/Properties/Resources.Designer.cs b/5_TSQLFormatter/Properties/Resources.Designer.cs index 04e1170..43d490c 100644 --- a/5_TSQLFormatter/Properties/Resources.Designer.cs +++ b/5_TSQLFormatter/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { using System; diff --git a/5_TSQLFormatter/Properties/Settings.Designer.cs b/5_TSQLFormatter/Properties/Settings.Designer.cs index efab29f..a4f99f6 100644 --- a/5_TSQLFormatter/Properties/Settings.Designer.cs +++ b/5_TSQLFormatter/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/5_TSQLFormatter/packages.config b/5_TSQLFormatter/packages.config index ce088d0..1da61fb 100644 --- a/5_TSQLFormatter/packages.config +++ b/5_TSQLFormatter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/6_TSQLVisualizer/6_TSQLVisualizer.csproj b/6_TSQLVisualizer/6_TSQLVisualizer.csproj index 317bcbd..a97a92a 100644 --- a/6_TSQLVisualizer/6_TSQLVisualizer.csproj +++ b/6_TSQLVisualizer/6_TSQLVisualizer.csproj @@ -59,8 +59,8 @@ false - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/6_TSQLVisualizer/Program.cs b/6_TSQLVisualizer/Program.cs index b4414f4..3a132df 100644 --- a/6_TSQLVisualizer/Program.cs +++ b/6_TSQLVisualizer/Program.cs @@ -38,17 +38,17 @@ using System.IO; using System.Reflection; -namespace GenericWalker +namespace SQLScriptDomSamples { class Program { static StringBuilder result = new StringBuilder(); static void Main(string[] args) { - var rdr = new StreamReader(@"c:\ScriptDom\sampleproc.sql"); + var rdr = new StreamReader(@"..\..\..\sampleproc.sql"); IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/6_TSQLVisualizer/packages.config b/6_TSQLVisualizer/packages.config index ce088d0..1da61fb 100644 --- a/6_TSQLVisualizer/packages.config +++ b/6_TSQLVisualizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/7_StatementLists/7_StatementLists.csproj b/7_StatementLists/7_StatementLists.csproj index 96192c5..158baa5 100644 --- a/7_StatementLists/7_StatementLists.csproj +++ b/7_StatementLists/7_StatementLists.csproj @@ -93,8 +93,8 @@ - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/7_StatementLists/Form1.Designer.cs b/7_StatementLists/Form1.Designer.cs index 62f328b..53ec118 100644 --- a/7_StatementLists/Form1.Designer.cs +++ b/7_StatementLists/Form1.Designer.cs @@ -1,4 +1,4 @@ -namespace TSQLFormatter +namespace SQLScriptDomSamples { partial class Form1 { diff --git a/7_StatementLists/Form1.cs b/7_StatementLists/Form1.cs index e8c1d47..58f627b 100644 --- a/7_StatementLists/Form1.cs +++ b/7_StatementLists/Form1.cs @@ -35,7 +35,7 @@ using System.IO; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { public partial class Form1 : Form { @@ -49,7 +49,7 @@ private void button1_Click(object sender, EventArgs e) using (var rdr = new StringReader(textBox1.Text)) { IList errors = null; - var parser = new TSql150Parser(true, SqlEngineType.All); + var parser = new TSql160Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) diff --git a/7_StatementLists/Program.cs b/7_StatementLists/Program.cs index 70f2e8f..3f688bf 100644 --- a/7_StatementLists/Program.cs +++ b/7_StatementLists/Program.cs @@ -32,7 +32,7 @@ using System; using System.Windows.Forms; -namespace TSQLFormatter +namespace SQLScriptDomSamples { static class Program { diff --git a/7_StatementLists/Properties/Resources.Designer.cs b/7_StatementLists/Properties/Resources.Designer.cs index 04e1170..43d490c 100644 --- a/7_StatementLists/Properties/Resources.Designer.cs +++ b/7_StatementLists/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { using System; diff --git a/7_StatementLists/Properties/Settings.Designer.cs b/7_StatementLists/Properties/Settings.Designer.cs index efab29f..a4f99f6 100644 --- a/7_StatementLists/Properties/Settings.Designer.cs +++ b/7_StatementLists/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TSQLFormatter.Properties { +namespace SQLScriptDomSamples.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config index ce088d0..1da61fb 100644 --- a/7_StatementLists/packages.config +++ b/7_StatementLists/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj index 61ec2d8..c20da5c 100644 --- a/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj +++ b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj @@ -34,8 +34,8 @@ 4 - - ..\packages\Microsoft.SqlServer.DacFx.160.6161.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/8_TSQLTextNormalizer/Program.cs b/8_TSQLTextNormalizer/Program.cs index bafec20..22e6e0d 100644 --- a/8_TSQLTextNormalizer/Program.cs +++ b/8_TSQLTextNormalizer/Program.cs @@ -33,7 +33,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace TSQLTextNormalizer +namespace SQLScriptDomSamples { using System; using System.IO; diff --git a/8_TSQLTextNormalizer/TSqlNormalizer.cs b/8_TSQLTextNormalizer/TSqlNormalizer.cs index 75b817d..600db20 100644 --- a/8_TSQLTextNormalizer/TSqlNormalizer.cs +++ b/8_TSQLTextNormalizer/TSqlNormalizer.cs @@ -28,7 +28,7 @@ // business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability // to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. //------------------------------------------------------------------------------ -namespace TSQLTextNormalizer +namespace SQLScriptDomSamples { using System; using System.Collections.Generic; @@ -101,7 +101,7 @@ internal string Normalize(Stream input, Stream output, int compatLevel, bool cas case 150: { scrgen = new Sql150ScriptGenerator(); - parser = new TSql150Parser(true); + parser = new TSql160Parser(true); break; } case 160: diff --git a/8_TSQLTextNormalizer/TSqlVisitor.cs b/8_TSQLTextNormalizer/TSqlVisitor.cs index 1a82b7a..1420394 100644 --- a/8_TSQLTextNormalizer/TSqlVisitor.cs +++ b/8_TSQLTextNormalizer/TSqlVisitor.cs @@ -28,7 +28,7 @@ // business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability // to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. //------------------------------------------------------------------------------ -namespace TSQLTextNormalizer +namespace SQLScriptDomSamples { using Microsoft.SqlServer.TransactSql.ScriptDom; diff --git a/8_TSQLTextNormalizer/packages.config b/8_TSQLTextNormalizer/packages.config index ce088d0..1da61fb 100644 --- a/8_TSQLTextNormalizer/packages.config +++ b/8_TSQLTextNormalizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/9_TSQLRewrite/9_TSQLRewrite.csproj b/9_TSQLRewrite/9_TSQLRewrite.csproj new file mode 100644 index 0000000..3005157 --- /dev/null +++ b/9_TSQLRewrite/9_TSQLRewrite.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {303F7887-FC8F-4237-AE88-39F81AF9274E} + Exe + Properties + TSQLRewrite + TSQLRewrite + v4.8 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9_TSQLRewrite/App.config b/9_TSQLRewrite/App.config new file mode 100644 index 0000000..4bfa005 --- /dev/null +++ b/9_TSQLRewrite/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/9_TSQLRewrite/Program.cs b/9_TSQLRewrite/Program.cs new file mode 100644 index 0000000..cbe24a2 --- /dev/null +++ b/9_TSQLRewrite/Program.cs @@ -0,0 +1,105 @@ +//------------------------------------------------------------------------------ +// The MIT License (MIT) +// +// Copyright (c) Arvind Shyamsundar +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This sample code is not supported under any Microsoft standard support program or service. +// The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. +// In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts +// be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, +// business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability +// to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. +//------------------------------------------------------------------------------ +// +// This example shows how to use the TransactSql.ScriptDom parser to potentially change script tokens +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace SQLScriptDomSamples +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using Microsoft.SqlServer.TransactSql.ScriptDom; + + class Program + { + static void Main(string[] args) + { + using (var rdr = new StreamReader(@"..\..\..\sampleproc.sql")) + { + IList errors = null; + var parser = new TSql150Parser(true, SqlEngineType.All); + var tree = parser.Parse(rdr, out errors); + + foreach (ParseError err in errors) + { + Console.WriteLine(err.Message); + } + + Console.WriteLine("Example of replacing tokens:"); + Console.WriteLine("============================"); + + // access, manipulate, and then print the script tokens + // this first loop is very simple, it just replaces < sign with > sign + for (int tmpLoop = tree.FirstTokenIndex; tmpLoop <= tree.LastTokenIndex; tmpLoop++) + { + if (tree.ScriptTokenStream[tmpLoop].TokenType == TSqlTokenType.LessThan) + { + //Console.WriteLine(string.Format("Token {0} is a 'less than' sign; changing it to 'greater than' sign", tmpLoop)); + tree.ScriptTokenStream[tmpLoop].TokenType = TSqlTokenType.GreaterThan; + tree.ScriptTokenStream[tmpLoop].Text = ">"; + } + + // print the output, which would include the re-written token + Console.Write(tree.ScriptTokenStream[tmpLoop].Text); + } + + Console.WriteLine("Example of dropping and injecting multiple tokens:"); + Console.WriteLine("=================================================="); + + // access, manipulate, and then print the script tokens + // this second loop is shows how to potentially delete and inject new tokens and build a new stream + // given we already modified the < sign to a > sign in the previous loop, we will look for a > sign + // and replace it with a >= sign + var outTokens = new List(); + for (int tmpLoop = tree.FirstTokenIndex; tmpLoop <= tree.LastTokenIndex; tmpLoop++) + { + if (tree.ScriptTokenStream[tmpLoop].TokenType == TSqlTokenType.GreaterThan) + { + //Console.WriteLine(string.Format("Token {0} is a 'less than' sign; dropping and injecting a 'greater than equal to' sign in the output", tmpLoop)); + // we ignore the original token and inject two tokens in the output; > and = + outTokens.Add(new TSqlParserToken(TSqlTokenType.GreaterThan, ">")); + outTokens.Add(new TSqlParserToken(TSqlTokenType.EqualsSign, "=")); + } + else + { + // add the token as-is + outTokens.Add(tree.ScriptTokenStream[tmpLoop]); + } + } + // print the output, which would include the re-written token + Console.Write(string.Join(string.Empty, outTokens.Select(t => t.Text))); + } + } + } +} diff --git a/9_TSQLRewrite/Properties/AssemblyInfo.cs b/9_TSQLRewrite/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b001029 --- /dev/null +++ b/9_TSQLRewrite/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TSQLRewrite")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TSQLRewrite")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("15c5cd8a-d960-4f45-a6ad-b3b13f9719c5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9_TSQLRewrite/packages.config b/9_TSQLRewrite/packages.config new file mode 100644 index 0000000..1da61fb --- /dev/null +++ b/9_TSQLRewrite/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SampleProc.sql b/SampleProc.sql index e70898e..741e6d4 100644 --- a/SampleProc.sql +++ b/SampleProc.sql @@ -1,3 +1,4 @@ +-- Some leading comments with < and > signs to test for later CREATE PROCEDURE [HumanResources].[uspUpdateEmployeeHireInfo] @BusinessEntityID [int], @JobTitle [nvarchar](50), @@ -32,7 +33,7 @@ BEGIN BEGIN CATCH -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog - IF @@TRANCOUNT > 0 + IF @@TRANCOUNT > 0 and 0 < 1 BEGIN ROLLBACK TRANSACTION; END diff --git a/ScriptDOMSamples.sln b/ScriptDOMSamples.sln index 61be54e..06d620d 100644 --- a/ScriptDOMSamples.sln +++ b/ScriptDOMSamples.sln @@ -26,78 +26,126 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "8_TSQLTextNormalizer", "8_TSQLTextNormalizer\8_TSQLTextNormalizer.csproj", "{D131443D-20C2-40F2-9D8B-6DA0EBE763B7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "9_TSQLRewrite", "9_TSQLRewrite\9_TSQLRewrite.csproj", "{303F7887-FC8F-4237-AE88-39F81AF9274E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|x64.ActiveCfg = Debug|Any CPU + {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|x64.Build.0 = Debug|Any CPU {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|x86.ActiveCfg = Debug|x86 {88301D6F-7C0B-4950-891D-999F991133A6}.Debug|x86.Build.0 = Debug|x86 {88301D6F-7C0B-4950-891D-999F991133A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {88301D6F-7C0B-4950-891D-999F991133A6}.Release|Any CPU.Build.0 = Release|Any CPU + {88301D6F-7C0B-4950-891D-999F991133A6}.Release|x64.ActiveCfg = Release|Any CPU + {88301D6F-7C0B-4950-891D-999F991133A6}.Release|x64.Build.0 = Release|Any CPU {88301D6F-7C0B-4950-891D-999F991133A6}.Release|x86.ActiveCfg = Release|x86 {88301D6F-7C0B-4950-891D-999F991133A6}.Release|x86.Build.0 = Release|x86 {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|x64.ActiveCfg = Debug|Any CPU + {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|x64.Build.0 = Debug|Any CPU {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|x86.ActiveCfg = Debug|x86 {46DADD69-CF9A-410D-805C-A24A8000327C}.Debug|x86.Build.0 = Debug|x86 {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|Any CPU.ActiveCfg = Release|Any CPU {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|Any CPU.Build.0 = Release|Any CPU + {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|x64.ActiveCfg = Release|Any CPU + {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|x64.Build.0 = Release|Any CPU {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|x86.ActiveCfg = Release|x86 {46DADD69-CF9A-410D-805C-A24A8000327C}.Release|x86.Build.0 = Release|x86 {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|x64.ActiveCfg = Debug|Any CPU + {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|x64.Build.0 = Debug|Any CPU {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|x86.ActiveCfg = Debug|x86 {3C51886E-96B8-4037-8D69-DED60EE1D557}.Debug|x86.Build.0 = Debug|x86 {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|Any CPU.ActiveCfg = Release|Any CPU {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|Any CPU.Build.0 = Release|Any CPU + {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|x64.ActiveCfg = Release|Any CPU + {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|x64.Build.0 = Release|Any CPU {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|x86.ActiveCfg = Release|x86 {3C51886E-96B8-4037-8D69-DED60EE1D557}.Release|x86.Build.0 = Release|x86 {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|x64.ActiveCfg = Debug|Any CPU + {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|x64.Build.0 = Debug|Any CPU {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|x86.ActiveCfg = Debug|x86 {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Debug|x86.Build.0 = Debug|x86 {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|Any CPU.Build.0 = Release|Any CPU + {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|x64.ActiveCfg = Release|Any CPU + {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|x64.Build.0 = Release|Any CPU {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|x86.ActiveCfg = Release|x86 {34808131-3AA3-4D50-A2C0-B47F93651A6E}.Release|x86.Build.0 = Release|x86 {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|x64.ActiveCfg = Debug|Any CPU + {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|x64.Build.0 = Debug|Any CPU {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|x86.ActiveCfg = Debug|x86 {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Debug|x86.Build.0 = Debug|x86 {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|Any CPU.ActiveCfg = Release|Any CPU {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|Any CPU.Build.0 = Release|Any CPU + {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|x64.ActiveCfg = Release|Any CPU + {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|x64.Build.0 = Release|Any CPU {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|x86.ActiveCfg = Release|x86 {D45AB243-99C3-4DD0-B692-835D3BF4E0C0}.Release|x86.Build.0 = Release|x86 {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|x64.ActiveCfg = Debug|Any CPU + {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|x64.Build.0 = Debug|Any CPU {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|x86.ActiveCfg = Debug|x86 {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Debug|x86.Build.0 = Debug|x86 {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|Any CPU.Build.0 = Release|Any CPU + {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x64.ActiveCfg = Release|Any CPU + {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x64.Build.0 = Release|Any CPU {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x86.ActiveCfg = Release|x86 {51E8719C-0ACA-4C79-AE31-7DE0DC0D5BE7}.Release|x86.Build.0 = Release|x86 {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x64.ActiveCfg = Debug|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x64.Build.0 = Debug|Any CPU {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x86.ActiveCfg = Debug|x86 {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Debug|x86.Build.0 = Debug|x86 {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|Any CPU.Build.0 = Release|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x64.ActiveCfg = Release|Any CPU + {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x64.Build.0 = Release|Any CPU {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.ActiveCfg = Release|x86 {82E6E27C-2B4D-4D83-A797-18EBF1F721F2}.Release|x86.Build.0 = Release|x86 {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x64.ActiveCfg = Debug|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x64.Build.0 = Debug|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x86.ActiveCfg = Debug|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Debug|x86.Build.0 = Debug|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|Any CPU.Build.0 = Release|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x64.ActiveCfg = Release|Any CPU + {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x64.Build.0 = Release|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x86.ActiveCfg = Release|Any CPU {D131443D-20C2-40F2-9D8B-6DA0EBE763B7}.Release|x86.Build.0 = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|x64.ActiveCfg = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|x64.Build.0 = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|x86.ActiveCfg = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Debug|x86.Build.0 = Debug|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|Any CPU.Build.0 = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|x64.ActiveCfg = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|x64.Build.0 = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|x86.ActiveCfg = Release|Any CPU + {303F7887-FC8F-4237-AE88-39F81AF9274E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From dbb0bd199f31ccea00186f4122592839d24028c0 Mon Sep 17 00:00:00 2001 From: Arvind Shyamsundar Date: Sat, 29 Apr 2023 08:21:37 -0700 Subject: [PATCH 9/9] Switch to ScriptDom nuget (#10) --- 1_BasicUsage/1_BasicUsage.csproj | 2 +- 1_BasicUsage/packages.config | 2 +- 2_VisitorPattern/2_VisitorPattern.csproj | 2 +- 2_VisitorPattern/packages.config | 2 +- 3_ScriptTokens/3_ScriptTokens.csproj | 2 +- 3_ScriptTokens/packages.config | 2 +- 4_TSQLValidation/4_TSQLValidation.csproj | 2 +- 4_TSQLValidation/packages.config | 2 +- 5_TSQLFormatter/5_TSQLFormatter.csproj | 2 +- 5_TSQLFormatter/packages.config | 2 +- 6_TSQLVisualizer/6_TSQLVisualizer.csproj | 2 +- 6_TSQLVisualizer/packages.config | 2 +- 7_StatementLists/7_StatementLists.csproj | 2 +- 7_StatementLists/packages.config | 2 +- 8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj | 2 +- 8_TSQLTextNormalizer/packages.config | 2 +- 9_TSQLRewrite/9_TSQLRewrite.csproj | 2 +- 9_TSQLRewrite/packages.config | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/1_BasicUsage/1_BasicUsage.csproj b/1_BasicUsage/1_BasicUsage.csproj index 8435d41..cc3d90c 100644 --- a/1_BasicUsage/1_BasicUsage.csproj +++ b/1_BasicUsage/1_BasicUsage.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/1_BasicUsage/packages.config b/1_BasicUsage/packages.config index 1da61fb..14c877b 100644 --- a/1_BasicUsage/packages.config +++ b/1_BasicUsage/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/2_VisitorPattern/2_VisitorPattern.csproj b/2_VisitorPattern/2_VisitorPattern.csproj index 2f7d1db..ac72bd9 100644 --- a/2_VisitorPattern/2_VisitorPattern.csproj +++ b/2_VisitorPattern/2_VisitorPattern.csproj @@ -70,7 +70,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/2_VisitorPattern/packages.config b/2_VisitorPattern/packages.config index 1da61fb..14c877b 100644 --- a/2_VisitorPattern/packages.config +++ b/2_VisitorPattern/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/3_ScriptTokens/3_ScriptTokens.csproj b/3_ScriptTokens/3_ScriptTokens.csproj index fae0e26..a5220c6 100644 --- a/3_ScriptTokens/3_ScriptTokens.csproj +++ b/3_ScriptTokens/3_ScriptTokens.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/3_ScriptTokens/packages.config b/3_ScriptTokens/packages.config index 1da61fb..14c877b 100644 --- a/3_ScriptTokens/packages.config +++ b/3_ScriptTokens/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/4_TSQLValidation/4_TSQLValidation.csproj b/4_TSQLValidation/4_TSQLValidation.csproj index f357d21..50b0406 100644 --- a/4_TSQLValidation/4_TSQLValidation.csproj +++ b/4_TSQLValidation/4_TSQLValidation.csproj @@ -94,7 +94,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/4_TSQLValidation/packages.config b/4_TSQLValidation/packages.config index 1da61fb..14c877b 100644 --- a/4_TSQLValidation/packages.config +++ b/4_TSQLValidation/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/5_TSQLFormatter/5_TSQLFormatter.csproj b/5_TSQLFormatter/5_TSQLFormatter.csproj index 3e90e08..ddac419 100644 --- a/5_TSQLFormatter/5_TSQLFormatter.csproj +++ b/5_TSQLFormatter/5_TSQLFormatter.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/5_TSQLFormatter/packages.config b/5_TSQLFormatter/packages.config index 1da61fb..14c877b 100644 --- a/5_TSQLFormatter/packages.config +++ b/5_TSQLFormatter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/6_TSQLVisualizer/6_TSQLVisualizer.csproj b/6_TSQLVisualizer/6_TSQLVisualizer.csproj index a97a92a..1704b9c 100644 --- a/6_TSQLVisualizer/6_TSQLVisualizer.csproj +++ b/6_TSQLVisualizer/6_TSQLVisualizer.csproj @@ -60,7 +60,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/6_TSQLVisualizer/packages.config b/6_TSQLVisualizer/packages.config index 1da61fb..14c877b 100644 --- a/6_TSQLVisualizer/packages.config +++ b/6_TSQLVisualizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/7_StatementLists/7_StatementLists.csproj b/7_StatementLists/7_StatementLists.csproj index 158baa5..714f8f3 100644 --- a/7_StatementLists/7_StatementLists.csproj +++ b/7_StatementLists/7_StatementLists.csproj @@ -94,7 +94,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/7_StatementLists/packages.config b/7_StatementLists/packages.config index 1da61fb..14c877b 100644 --- a/7_StatementLists/packages.config +++ b/7_StatementLists/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj index c20da5c..45aaf92 100644 --- a/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj +++ b/8_TSQLTextNormalizer/8_TSQLTextNormalizer.csproj @@ -35,7 +35,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/8_TSQLTextNormalizer/packages.config b/8_TSQLTextNormalizer/packages.config index 1da61fb..14c877b 100644 --- a/8_TSQLTextNormalizer/packages.config +++ b/8_TSQLTextNormalizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/9_TSQLRewrite/9_TSQLRewrite.csproj b/9_TSQLRewrite/9_TSQLRewrite.csproj index 3005157..8286645 100644 --- a/9_TSQLRewrite/9_TSQLRewrite.csproj +++ b/9_TSQLRewrite/9_TSQLRewrite.csproj @@ -35,7 +35,7 @@ - ..\packages\Microsoft.SqlServer.DacFx.161.6374.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll + ..\packages\Microsoft.SqlServer.TransactSql.ScriptDom.161.8812.0\lib\net462\Microsoft.SqlServer.TransactSql.ScriptDom.dll diff --git a/9_TSQLRewrite/packages.config b/9_TSQLRewrite/packages.config index 1da61fb..14c877b 100644 --- a/9_TSQLRewrite/packages.config +++ b/9_TSQLRewrite/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file