Skip to content

Commit

Permalink
LineSorter 4.5
Browse files Browse the repository at this point in the history
- New cool icon by Dessader :3
- New compilers support (no more limitations when creating custom sorts)
- Fixed inappropriate create-custom-sort window behavior
- Ha-ha. From the very first version I forgot about character escaping in regex: "/*.*/"
  • Loading branch information
Kir-Antipov committed Apr 29, 2019
1 parent fc149bd commit 9eb8294
Show file tree
Hide file tree
Showing 12 changed files with 322 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Roslyn Path
roslyn/

# Build results
[Dd]ebug/
[Dd]ebugPublic/
Expand Down
22 changes: 12 additions & 10 deletions LineSorter/Commands/UserSort/FormCreateFunc.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion LineSorter/Commands/UserSort/FormCreateFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Globalization;
using System.Windows.Forms;
using System.CodeDom.Compiler;
using Microsoft.CodeDom.Providers.DotNetCompilerPlatform;

namespace LineSorter.Commands.UserSort
{
Expand All @@ -30,6 +31,7 @@ public partial class FormCreateFunc : Form
private string[] DefaultAssemblies { get; } = new string[] {
"System",
"System.Xml",
"System.Web", // Ha-ha, funny joke, Roslyn... (vbc.exe doesn't work without this reference)
"System.Core",
"System.Data",
"System.Net.Http",
Expand All @@ -40,6 +42,30 @@ public partial class FormCreateFunc : Form
};
public new IUserSort DialogResult { get; private set; }
private static ResourceManager<FormCreateFunc> Manager { get; } = ResourceManager<FormCreateFunc>.Instance;

private abstract class CompilerSettings : ICompilerSettings
{
public string CompilerFullPath { get; }
public int CompilerServerTimeToLive { get; }

protected CompilerSettings(string CompilerName)
{
CompilerFullPath = Path.Combine(Path.GetDirectoryName(VSPackage.DllLocation), $"roslyn\\{CompilerName}.exe");
CompilerServerTimeToLive = 0;
}
}
private class CSCompilerSettings : CompilerSettings
{
public static ICompilerSettings Instance { get; } = new CSCompilerSettings();

private CSCompilerSettings() : base("csc") { }
}
private class VBCompilerSettings : CompilerSettings
{
public static ICompilerSettings Instance { get; } = new VBCompilerSettings();

private VBCompilerSettings() : base("vbc") { }
}
#endregion

#region Init
Expand Down Expand Up @@ -213,7 +239,7 @@ End Class
CompilerParameters options = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = false, OutputAssembly = $"{SavePath}{guid}.dll" };
foreach (string a in DefaultAssemblies.Select(x => x.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || x.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ? x : $"{x}.dll"))
options.ReferencedAssemblies.Add(a);
CompilerResults results = (isCSharp ? new Microsoft.CSharp.CSharpCodeProvider() : (CodeDomProvider)new Microsoft.VisualBasic.VBCodeProvider()).CompileAssemblyFromSource(options, resultCode);
CompilerResults results = (isCSharp ? new CSharpCodeProvider(CSCompilerSettings.Instance) : (CodeDomProvider)new VBCodeProvider(VBCompilerSettings.Instance)).CompileAssemblyFromSource(options, resultCode);
if (results.Errors.HasErrors)
ShowError(string.Join(Environment.NewLine + Environment.NewLine, results.Errors.Cast<CompilerError>().Where(x => !x.IsWarning).Select(x => x.ErrorText)));
else
Expand Down Expand Up @@ -298,6 +324,9 @@ private void TextMain_TextChanged(object sender, EventArgs e)
}

private void FormCreateFunc_Load(object sender, EventArgs e) => ControlBox = ShowIcon = MinimizeBox = MaximizeBox = false;

private void TextMain_Enter(object sender, EventArgs e) => AcceptButton = null;
private void TextMain_Leave(object sender, EventArgs e) => AcceptButton = buttCompile;
#endregion
}
}
4 changes: 2 additions & 2 deletions LineSorter/Commands/UserSort/LangBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public Token(Regex Regex, Color Color, bool NeedWhitespace)
public LangBox()
{
Tokens = new Token[] {
new Token(new Regex("namespace|unchecked|continue|delegate|checked|decimal|default|public|static|using|finally|foreach|double|object|params|return|sizeof|string|switch|typeof|unsafe|ushort|break|catch|const|false|fixed|float|sbyte|short|throw|ulong|while|bool|byte|case|char|else|goto|lock|long|null|true|uint|void|Void|for|int|new|out|ref|try|as|do|if|in|is|ByVal|ByRef|As|Of|Optional|ParamArray|If|Else|And|Or|Xor|False|True|And|AndAlso|Is|IsNot|Like|Mod|OrElse|Then|Sub|End|Function|Public|Return|CType"), KeywordColor, true),
new Token(new Regex("namespace|unchecked|continue|delegate|checked|decimal|default|public|static|using|finally|foreach|double|object|params|return|sizeof|string|switch|typeof|unsafe|ushort|break|catch|const|false|fixed|float|sbyte|short|throw|ulong|while|bool|byte|case|char|else|goto|lock|long|null|true|uint|void|Void|for|int|new|out|ref|try|as|do|if|in|is|ByVal|ByRef|As|Of|Optional|ParamArray|If|Else|And|Or|Xor|False|True|And|AndAlso|Is|IsNot|Like|Mod|OrElse|Then|Sub|End|Function|Public|Return|CType|var"), KeywordColor, true),
new Token(new Regex("IEnumerable|Random|Boolean|Regex|Match|MatchCollection|Int16|Int32|Int64|Integer|String|Char|Decimal|Double|Float|Delegate|Action|Row"), ClassColor, true),
new Token(new Regex("([-]+)?[0-9]+"), NumericColor, true),
new Token(new Regex("\".*\""), StringColor, false),
new Token(new Regex("@\".*\"", RegexOptions.Singleline), StringColor, false),
new Token(new Regex("/*.*/", RegexOptions.Singleline), CommentColor, false),
new Token(new Regex(@"/\*.*\*/", RegexOptions.Singleline), CommentColor, false),
new Token(new Regex("//.*"), CommentColor, false),
new Token(new Regex("''.*"), CommentColor, false)
};
Expand Down
Binary file added LineSorter/Images/Donate Button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LineSorter/Images/VSPackageIcon.ico
Binary file not shown.
Loading

0 comments on commit 9eb8294

Please sign in to comment.