8000 PowerUp: Added support for .NET 7, and support for older runtimes suc… · badamczewski/PowerUp@e6ef30d · GitHub
[go: up one dir, main page]

Skip to content

Commit e6ef30d

Browse files
committed
PowerUp: Added support for .NET 7, and support for older runtimes such as core3.1
1 parent 16afbe9 commit e6ef30d

File tree

14 files changed

+37
-34
lines changed

14 files changed

+37
-34
lines changed

src/PowerUp.Core/Compilation/CodeRewriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace PowerUp.Core.Compilation
1212
public class CodeRewriter : CSharpSyntaxRewriter
1313
{
1414
private readonly CompilationOptions _options;
15-
private readonly StringBuilder _benchCodeBuilder = new();
16-
private readonly StringBuilder _usingBuilder = new();
17-
private readonly StringBuilder _structSizeOfbuilder = new();
15+
private readonly StringBuilder _benchCodeBuilder = new StringBuilder();
16+
private readonly StringBuilder _usingBuilder = new StringBuilder();
17+
private readonly StringBuilder _structSizeOfbuilder = new StringBuilder();
1818

1919
public CodeRewriter(CompilationOptions options)
2020
{

src/PowerUp.Core/Compilation/CompilationUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CompilationOptions
2828
// The compilation map, maps specific compilation instructions to language objects
2929
// like methods, structs, classes fields and other.
3030
//
31-
public Dictionary<string, string> CompilationMap { get; set; } = new();
31+
public Dictionary<string, string> CompilationMap { get; set; } = new Dictionary<string, string>();
3232
/// <summary>
3333
/// Should help be displayed by the watcher.
3434
/// </summary>

src/PowerUp.Core/Compilation/IL/ILClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class ILClass
66
{
77
//Fields
88
//Methods
9-
public List<ILMethod> Methods { get; set; } = new();
9+
public List<ILMethod> Methods { get; set; } = new List<ILMethod>();
1010
//Other Classes / Structs
1111
}
1212
}

src/PowerUp.Core/Compilation/IL/ILCompilationUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ namespace PowerUp.Core.Compilation
77
public class ILCompilationUnit
88
{
99
public Type CompiledType { get; set; }
10-
public List<Error> Errors { get; set; } = new();
10+
public List<Error> Errors { get; set; } = new List<Error>();
1111
}
1212
}

src/PowerUp.Core/Compilation/IL/ILMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ILMethod
99
public string Accessor { get; set; }
1010
public string InstanceType { get; set; }
1111
public string Name { get; set; }
12-
public List<ILMethodArg> Args { get; set; } = new();
13-
public List<ILInst> Code { get; set; } = new();
12+
public List<ILMethodArg> Args { get; set; } = new List<ILMethodArg>();
13+
public List<ILInst> Code { get; set; } = new List<ILInst>();
1414
}
1515
}

src/PowerUp.Core/Compilation/IL/ILParseResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace PowerUp.Core.Compilation
55
{
66
public class ILParseResult
77
{
8-
public List<ILClass> Classes { get; set; } = new();
9-
public List<Error> Errors { get; set; } = new();
8+
public List<ILClass> Classes { get; set; } = new List<ILClass>();
9+
public List<Error> Errors { get; set; } = new List<Error>();
1010
}
1111
}

src/PowerUp.Core/Decompilation/DebugInfoProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public DebugInfoProvider(Stream pdbStream)
3838

3939
public IList<ICSharpCode.Decompiler.DebugInfo.SequencePoint> GetSequencePoints(MethodDefinitionHandle method)
4040
{
41-
List<ICSharpCode.Decompiler.DebugInfo.SequencePoint> sequencePoints = new();
41+
List<ICSharpCode.Decompiler.DebugInfo.SequencePoint> sequencePoints = new List<ICSharpCode.Decompiler.DebugInfo.SequencePoint>();
4242
var info = _metadataReader.GetMethodDebugInformation(method);
4343
var points = info.GetSequencePoints();
4444

src/PowerUp.Core/Decompilation/DecompiledMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public class DecompiledMethod : MethodSignature
9191
public bool IsVisible { get; set; } = true;
9292
public uint CodeSize { get; set; }
9393
public ulong CodeAddress { get; set; }
94-
public List<string> Messages { get; set; } = new();
95-
public List<MethodSignature> Calls { get; set; } = new();
94+
public List<string> Messages { get; set; } = new List<string>();
95+
public List<MethodSignature> Calls { get; set; } = new List<MethodSignature>();
9696
public override string ToString()
9797
{
9898
StringBuilder builder = new StringBuilder();

src/PowerUp.Tests/appsettings.json

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

src/PowerUp.Watcher/CSharpWatcher.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,33 @@ private void Initialize(string csharpFile, string outAsmFile, string outILFile,
133133
XConsole.WriteLine(IsDebug ? "'[DEBUG]'" : "`[RELEASE]`");
134134
}
135135

136+
137+
//
138+
// @TODO @DESIGN: Not sure if I like this.
139+
// All watchers should be albe to run on any installed runtime and this should
140+
// be a dynamic process (the user should be albe to use a command flag)
141+
//
142+
// To be able to do this, the C# and F# (dotnet) watchers would need to work by calling
143+
// a seperate decompilation / dissasembly process.
144+
//
136145
public void InitializeCsharpCompiler()
137146
{
138-
if (Environment.Version.Major == 5)
147+
if(Environment.Version.Major == 3)
148+
{
149+
_compiler = new CSharpCodeCompiler(_configuration["DotNetCoreDirPathNet3"]);
150+
}
151+
else if (Environment.Version.Major == 5)
139152
{
140153
_compiler = new CSharpCodeCompiler(_configuration["DotNetCoreDirPathNet5"]);
141154
}
142155
else if (Environment.Version.Major == 6)
143156
{
144157
_compiler = new CSharpCodeCompiler(_configuration["DotNetCoreDirPathNet6"], LanguageVersion.Default);
145158
}
159+
else if (Environment.Version.Major == 7)
160+
{
161+
_compiler = new CSharpCodeCompiler(_configuration["DotNetCoreDirPathNet7"], LanguageVersion.Default);
162+
}
146163
else
147164
{
148165
_compiler = new CSharpCodeCompiler(_configuration["DotNetCoreDirPathDefault"]);
@@ -869,7 +886,7 @@ public DecompilationUnit DecompileToASM(string code)
869886
}
870887
else if (attribute == "PGO")
871888
{
872-
List<string> messages = new();
889+
List<string> messages = new List<string>();
873890
//
874891
// If PGO is not enabled then don't even bother running any methods.
875892
//

0 commit comments

Comments
 (0)
0