From 8aa51b940faf79396e17e2a4ae445b9b7e59b66f Mon Sep 17 00:00:00 2001 From: codFather2 Date: Tue, 13 Feb 2018 17:15:05 +0300 Subject: [PATCH 01/12] WIP: AddRoslyn --- CSharpMinifier.GUI/App.config | 34 ++++- CSharpMinifier.GUI/CSharpMinifier.GUI.csproj | 4 +- .../Properties/Resources.Designer.cs | 4 +- .../Properties/Settings.Designer.cs | 2 +- CSharpMinifier.GUI/frmMain.cs | 2 +- .../CSharpMinifier.Tests.csproj | 5 +- CSharpMinifier.Tests/app.config | 31 +++++ CSharpMinifier/CSharpMinifier.csproj | 88 ++++++++++++- CSharpMinifier/IMinifier.cs | 11 ++ CSharpMinifier/Minifier.cs | 5 +- CSharpMinifier/Rewriters/CSharpRewriter.cs | 80 ++++++++++++ CSharpMinifier/RoslynMinifier.cs | 119 ++++++++++++++++++ CSharpMinifier/app.config | 31 +++++ CSharpMinifier/packages.config | 43 +++++++ 14 files changed, 444 insertions(+), 15 deletions(-) create mode 100644 CSharpMinifier.Tests/app.config create mode 100644 CSharpMinifier/IMinifier.cs create mode 100644 CSharpMinifier/Rewriters/CSharpRewriter.cs create mode 100644 CSharpMinifier/RoslynMinifier.cs create mode 100644 CSharpMinifier/app.config diff --git a/CSharpMinifier.GUI/App.config b/CSharpMinifier.GUI/App.config index f8ac8ea..58a5513 100644 --- a/CSharpMinifier.GUI/App.config +++ b/CSharpMinifier.GUI/App.config @@ -1,12 +1,12 @@ - + -
+
- + @@ -72,4 +72,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CSharpMinifier.GUI/CSharpMinifier.GUI.csproj b/CSharpMinifier.GUI/CSharpMinifier.GUI.csproj index ec4383a..3172442 100644 --- a/CSharpMinifier.GUI/CSharpMinifier.GUI.csproj +++ b/CSharpMinifier.GUI/CSharpMinifier.GUI.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties CSharpMinifier.GUI CSharpMinifier.GUI - v4.5 + v4.6 512 diff --git a/CSharpMinifier.GUI/Properties/Resources.Designer.cs b/CSharpMinifier.GUI/Properties/Resources.Designer.cs index f33943e..a3d61f5 100644 --- a/CSharpMinifier.GUI/Properties/Resources.Designer.cs +++ b/CSharpMinifier.GUI/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace CSharpMinifier.GUI.Properties { // 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", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/CSharpMinifier.GUI/Properties/Settings.Designer.cs b/CSharpMinifier.GUI/Properties/Settings.Designer.cs index d83e7f8..d4972a9 100644 --- a/CSharpMinifier.GUI/Properties/Settings.Designer.cs +++ b/CSharpMinifier.GUI/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace CSharpMinifier.GUI.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/CSharpMinifier.GUI/frmMain.cs b/CSharpMinifier.GUI/frmMain.cs index a15b4e9..0c84aca 100644 --- a/CSharpMinifier.GUI/frmMain.cs +++ b/CSharpMinifier.GUI/frmMain.cs @@ -125,7 +125,7 @@ private void btnMinify_Click(object sender, EventArgs e) EnumToIntConversion = cbEnumToIntConversion.Checked, Unsafe = cbUnsafe.Checked }; - Minifier minifier = new Minifier(minifierOptions); + IMinifier minifier = new RoslynMinifier(minifierOptions); tbOutput.Text = !cbMinifyFiles.Checked ? minifier.MinifyFromString(tbInput.Text) : minifier.MinifyFiles(Sources.Select(source => source.Value).ToArray()); tbInputLength.Text = tbInput.Text.Length.ToString(); diff --git a/CSharpMinifier.Tests/CSharpMinifier.Tests.csproj b/CSharpMinifier.Tests/CSharpMinifier.Tests.csproj index 58e2244..53ecf4a 100644 --- a/CSharpMinifier.Tests/CSharpMinifier.Tests.csproj +++ b/CSharpMinifier.Tests/CSharpMinifier.Tests.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties CSharpMinifier.Tests CSharpMinifier.Tests - v4.5 + v4.6 512 @@ -53,6 +53,7 @@ + diff --git a/CSharpMinifier.Tests/app.config b/CSharpMinifier.Tests/app.config new file mode 100644 index 0000000..9b6361b --- /dev/null +++ b/CSharpMinifier.Tests/app.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharpMinifier/CSharpMinifier.csproj b/CSharpMinifier/CSharpMinifier.csproj index a59b708..81482cf 100644 --- a/CSharpMinifier/CSharpMinifier.csproj +++ b/CSharpMinifier/CSharpMinifier.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties CSharpMinifier CSharpMinifier - v4.5 + v4.6 512 @@ -50,6 +50,12 @@ False ..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.Xml.dll + + ..\packages\Microsoft.CodeAnalysis.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + + + ..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + False ..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.dll @@ -67,10 +73,80 @@ ..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.Rocks.dll + + ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + True + + + ..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + + + ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + + ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll + True + + + ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + + + ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + + + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + + + ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + + @@ -84,13 +160,21 @@ + + + Designer + + + + +