Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 4b6b2e5

Browse files
author
Zaczero
committed
Revert "Added C# 7.0 support #4"
This reverts commit e175aa4.
1 parent e175aa4 commit 4b6b2e5

File tree

9 files changed

+22
-138
lines changed

9 files changed

+22
-138
lines changed

SharpLoader/App.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
55
</startup>
6-
</configuration>
6+
</configuration>

SharpLoader/Core/RuntimeCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.CodeDom.Compiler;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5-
using Microsoft.CodeDom.Providers.DotNetCompilerPlatform;
5+
using Microsoft.CSharp;
66

77
namespace SharpLoader.Core
88
{
@@ -12,7 +12,7 @@ public class RuntimeCompiler
1212

1313
public RuntimeCompiler()
1414
{
15-
_compiler = new CSharpCodeProvider();
15+
_compiler = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
1616
}
1717

1818
public bool Compile(string outputName, string compilerArguments, string[] assemblies, params string[] sources)

SharpLoader/FodyWeavers.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

SharpLoader/Program.cs

Lines changed: 14 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.IO.Compression;
66
using System.Linq;
7-
using System.Reflection;
87
using System.Runtime.InteropServices;
98
using System.Security.Cryptography;
109
using System.Text;
@@ -15,6 +14,10 @@ namespace SharpLoader
1514
{
1615
public static class Program
1716
{
17+
/* Limitations:
18+
* supports only c# 5.0
19+
*/
20+
1821
/* Exit codes:
1922
* 0 - default
2023
* 1 - data file not found
@@ -35,19 +38,18 @@ public static class Program
3538
private const int SW_SHOW = 5;
3639

3740
public const string Author = "Zaczero";
38-
public const string Version = "2.1";
41+
public const string Version = "2.0.1";
3942

4043
private const int ReadBufferSize = ushort.MaxValue;
4144

4245
private const string ConfigFileName = "SharpLoader.ini";
4346
private static readonly string MyPath = Process.GetCurrentProcess().MainModule.FileName;
4447
private static readonly string MyDirectory = Path.GetDirectoryName(MyPath);
45-
public static string ConfigPath;
48+
public static string ConfigPath = Path.Combine(MyDirectory, ConfigFileName);
4649

4750
public static List<string> DragDropPaths;
4851
public static int Seed = -1;
4952
public static string Hash;
50-
public static string SaveDir;
5153

5254
private static MainForm _form;
5355
private static bool _outToConsole;
@@ -67,7 +69,7 @@ public static void Main(string[] args)
6769
for (var i = 0; i < args.Length; i++)
6870
{
6971
// Argument is path
70-
if ((File.Exists(args[i]) || Directory.Exists(args[i])) && Path.GetExtension(args[i]) != ".exe")
72+
if (args[i] != MyPath && (File.Exists(args[i]) || Directory.Exists(args[i])))
7173
{
7274
// Directory
7375
if (File.GetAttributes(args[i]).HasFlag(FileAttributes.Directory))
@@ -92,12 +94,6 @@ public static void Main(string[] args)
9294
// Normal argument
9395
else
9496
{
95-
if (args[i] == "-cmd")
96-
{
97-
cmdMode = true;
98-
continue;
99-
}
100-
10197
// Multiple arguments
10298
if (i + 1 < args.Length)
10399
{
@@ -109,12 +105,14 @@ public static void Main(string[] args)
109105
{
110106
throw new Exception($"invalid seed value: {args[i + 1]}");
111107
}
112-
i++;
113108
}
114-
else if (args[i] == "-path")
109+
}
110+
// Single argument
111+
else
112+
{
113+
if (args[i] == "-cmd")
115114
{
116-
SaveDir = args[i + 1];
117-
i++;
115+
cmdMode = true;
118116
}
119117
}
120118
}
@@ -126,18 +124,6 @@ public static void Main(string[] args)
126124
Seed = new Random(Environment.TickCount).Next(0, int.MaxValue);
127125
}
128126

129-
if (string.IsNullOrEmpty(SaveDir))
130-
{
131-
ConfigPath = Path.Combine(MyDirectory, ConfigFileName);
132-
SaveDir = MyDirectory;
133-
}
134-
else
135-
{
136-
ConfigPath = Path.Combine(SaveDir, ConfigFileName);
137-
}
138-
139-
DumpToAppData();
140-
141127
// Show UI
142128
if (!cmdMode)
143129
{
@@ -175,55 +161,6 @@ public static void Main(string[] args)
175161
}
176162
}
177163

178-
public static void DumpToAppData()
179-
{
180-
var appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SharpLoader");
181-
var exePath = Path.Combine(appDataPath, "SharpLoader.exe");
182-
var thisPath = Process.GetCurrentProcess().MainModule.FileName;
183-
184-
if (thisPath != exePath)
185-
{
186-
if (!Directory.Exists(appDataPath))
187-
{
188-
Directory.CreateDirectory(appDataPath);
189-
}
190-
191-
// Run the newest file
192-
File.Copy(thisPath, exePath, true);
193-
194-
var argsString = string.Empty;
195-
foreach (var arg in Environment.GetCommandLineArgs())
196-
{
197-
if (File.Exists(arg))
198-
{
199-
argsString += $"\"{arg}\" ";
200-
}
201-
else
202-
{
203-
argsString += $"{arg} ";
204-
}
205-
}
206-
argsString = argsString.TrimEnd(' ');
207-
208-
Process.Start(exePath, $"{argsString} -path \"{SaveDir}\"");
209-
Environment.Exit(0);
210-
}
211-
212-
var binPath = Path.Combine(appDataPath, "bin");
213-
var binZipPath = Path.Combine(appDataPath, "bin.zip");
214-
215-
if (!Directory.Exists(binPath))
216-
{
217-
if (!File.Exists(binZipPath))
218-
{
219-
WriteResourceToFile("SharpLoader.bin.zip", binZipPath);
220-
}
221-
222-
ZipFile.ExtractToDirectory(binZipPath, binPath);
223-
File.Delete(binZipPath);
224-
}
225-
}
226-
227164
public static int Compile()
228165
{
229166
var randomizer = new SourceRandomizer(Seed);
@@ -302,8 +239,6 @@ public static int Compile()
302239
return 2;
303240
}
304241

305-
outputName = Path.Combine(SaveDir, outputName);
306-
307242
// Read sources
308243
var userSourceFiles = new List<string>();
309244

@@ -475,10 +410,8 @@ public static int Compile()
475410
return 4;
476411
}
477412

478-
int.TryParse("lol", out int parseeed);
479-
480413
Console.ForegroundColor = ConsoleColor.Green;
481-
Out($"-=: Done [{Path.GetFileName(outputName)}] {(_outToConsole ? "(press any key to exit)" : string.Empty)}");
414+
Out($"-=: Done [{outputName}] {(_outToConsole ? "(press any key to exit)" : string.Empty)}");
482415

483416
var sourceBytes = new List<byte>();
484417
foreach (var s in compileSourceFiles)
@@ -549,17 +482,6 @@ public static void CleanTemp()
549482
}
550483
}
551484

552-
private static void WriteResourceToFile(string resourceName, string fileName)
553-
{
554-
using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
555-
{
556-
using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
557-
{
558-
resource.CopyTo(file);
559-
}
560-
}
561-
}
562-
563485
private static IEnumerable<string> GetFilesFromDirectory(string directory)
564486
{
565487
var dir = new DirectoryInfo(directory);

SharpLoader/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("2.1.0.0")]
35-
[assembly: AssemblyFileVersion("2.1.0.0")]
34+
[assembly: AssemblyVersion("2.0.1.0")]
35+
[assembly: AssemblyFileVersion("2.0.1.0")]

SharpLoader/SelectForm.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ private void ThemeKeyDown(object sender, KeyEventArgs e)
3232

3333
private void CloseClick(object sender, EventArgs e)
3434
{
35-
Program.CleanTemp();
3635
Application.Exit();
3736
}
3837

SharpLoader/SharpLoader.csproj

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
4-
<Import Project="packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props')" />
53
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
64
<PropertyGroup>
75
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -10,12 +8,11 @@
108
<OutputType>Exe</OutputType>
119
<RootNamespace>SharpLoader</RootNamespace>
1210
<AssemblyName>SharpLoader</AssemblyName>
13-
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1412
<FileAlignment>512</FileAlignment>
1513
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1614
<NuGetPackageImportStamp>
1715
</NuGetPackageImportStamp>
18-
<TargetFrameworkProfile />
1916
</PropertyGroup>
2017
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2118
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -43,13 +40,6 @@
4340
<ApplicationManifest>app.manifest</ApplicationManifest>
4441
</PropertyGroup>
4542
<ItemGroup>
46-
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
47-
<HintPath>packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
48-
<Private>False</Private>
49-
</Reference>
50-
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51-
<HintPath>packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
52-
</Reference>
5343
<Reference Include="System" />
5444
<Reference Include="System.Data" />
5545
<Reference Include="System.Drawing" />
@@ -91,8 +81,6 @@
9181
</ItemGroup>
9282
<ItemGroup>
9383
<None Include="app.manifest" />
94-
<EmbeddedResource Include="bin.zip" />
95-
<None Include="packages.config" />
9684
<None Include="Properties\Resources.resx">
9785
<Generator>ResXFileCodeGenerator</Generator>
9886
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -109,19 +97,5 @@
10997
<DependentUpon>SelectForm.cs</DependentUpon>
11098
</EmbeddedResource>
11199
</ItemGroup>
112-
<ItemGroup>
113-
<None Include="FodyWeavers.xml" />
114-
</ItemGroup>
115100
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
116-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
117-
<PropertyGroup>
118-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
119-
</PropertyGroup>
120-
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props'))" />
121-
<Error Condition="!Exists('packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
122-
<Error Condition="!Exists('packages\Fody.2.1.0\build\netstandard1.0\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.2.1.0\build\netstandard1.0\Fody.targets'))" />
123-
<Error Condition="!Exists('packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
124-
</Target>
125-
<Import Project="packages\Fody.2.1.0\build\netstandard1.0\Fody.targets" Condition="Exists('packages\Fody.2.1.0\build\netstandard1.0\Fody.targets')" />
126-
<Import Project="packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
127101
</Project>

SharpLoader/bin.zip

-6.56 MB
Binary file not shown.

SharpLoader/packages.config

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)