Skip to content

Commit

Permalink
Add net45 tfm
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Oct 11, 2019
1 parent bd4111b commit b182d5d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ jobs:
- name: Build
shell: pwsh
run: |
$env:PATH = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64;' + $env:PATH
$msbuildPath = Join-Path (Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio" | Where-Object { $_.Name -match '^\d{4}$' -and $_.PSIsContainer } | Sort-Object Name -Descending)[0] 'Enterprise\MSBuild\Current\Bin\amd64'
$env:PATH = $msbuildPath + ';' + $env:PATH
.\build.ps1
- uses: actions/upload-artifact@v1
with:
name: de4dot-net35
path: Release/net35

- uses: actions/upload-artifact@v1
with:
name: de4dot-net45
path: Release/net45

- uses: actions/upload-artifact@v1
with:
name: de4dot-netcoreapp2.1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ bin/
obj/
Release/
Debug/
publish-netcoreapp*/
launchSettings.json
*.user
12 changes: 6 additions & 6 deletions AssemblyData/methodsrewriter/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static CodeGenerator() {
IMethodsRewriter methodsRewriter;
string methodName;
IList<Instruction> allInstructions;
IList<ExceptionHandler> allExceptionHandlers;
IList<dnlib.DotNet.Emit.ExceptionHandler> allExceptionHandlers;
ILGenerator ilg;
Type methodReturnType;
Type[] methodParameters;
Expand All @@ -67,7 +67,7 @@ static CodeGenerator() {
List<LocalBuilder> locals;
List<Label> labels;
Dictionary<Instruction, int> instrToIndex;
Stack<ExceptionHandler> exceptionHandlersStack;
Stack<dnlib.DotNet.Emit.ExceptionHandler> exceptionHandlersStack;

public Type DelegateType => delegateType;

Expand All @@ -83,7 +83,7 @@ public void SetMethodInfo(MMethod methodInfo) {
delegateType = Utils.GetDelegateType(methodReturnType, methodParameters);
}

public Delegate Generate(IList<Instruction> allInstructions, IList<ExceptionHandler> allExceptionHandlers) {
public Delegate Generate(IList<Instruction> allInstructions, IList<dnlib.DotNet.Emit.ExceptionHandler> allExceptionHandlers) {
this.allInstructions = allInstructions;
this.allExceptionHandlers = allExceptionHandlers;

Expand All @@ -95,7 +95,7 @@ public Delegate Generate(IList<Instruction> allInstructions, IList<ExceptionHand
InitLocals();
InitLabels();

exceptionHandlersStack = new Stack<ExceptionHandler>();
exceptionHandlersStack = new Stack<dnlib.DotNet.Emit.ExceptionHandler>();
for (int i = 0; i < allInstructions.Count; i++) {
UpdateExceptionHandlers(i);
var instr = allInstructions[i];
Expand Down Expand Up @@ -143,7 +143,7 @@ void UpdateExceptionHandlers(Instruction instr) {
}

bool AddTryStart(Instruction instr) {
var list = new List<ExceptionHandler>();
var list = new List<dnlib.DotNet.Emit.ExceptionHandler>();
foreach (var ex in allExceptionHandlers) {
if (ex.TryStart == instr)
list.Add(ex);
Expand All @@ -159,7 +159,7 @@ bool AddTryStart(Instruction instr) {
return list.Count > 0;
}

static bool IsSameTryBlock(ExceptionHandler ex1, ExceptionHandler ex2) => ex1.TryStart == ex2.TryStart && ex1.TryEnd == ex2.TryEnd;
static bool IsSameTryBlock(dnlib.DotNet.Emit.ExceptionHandler ex1, dnlib.DotNet.Emit.ExceptionHandler ex2) => ex1.TryStart == ex2.TryStart && ex1.TryEnd == ex2.TryEnd;

void InitInstrToIndex() {
instrToIndex = new Dictionary<Instruction, int>(allInstructions.Count);
Expand Down
2 changes: 1 addition & 1 deletion De4DotCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<De4DotNetFramework>false</De4DotNetFramework>
<De4DotNetFramework Condition=" '$(SolutionName)' == 'de4dot.netframework' ">true</De4DotNetFramework>
<!-- Two different sln files are used because some of the projects are only available when targetting .NET Framework -->
<TargetFrameworks Condition=" '$(De4DotNetFramework)' == 'true' ">net35</TargetFrameworks>
<TargetFrameworks Condition=" '$(De4DotNetFramework)' == 'true' ">net35;net45</TargetFrameworks>
<TargetFrameworks Condition=" '$(De4DotNetFramework)' != 'true' ">netcoreapp3.0;netcoreapp2.1</TargetFrameworks>
<Features>strict</Features>
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 4 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ msbuild -v:m -restore -t:Build -p:Configuration=Release -p:TargetFramework=net35
if ($LASTEXITCODE) { exit $LASTEXITCODE }
Remove-Item Release\net35\*.pdb, Release\net35\*.xml, Release\net35\Test.Rename.*

msbuild -v:m -restore -t:Build -p:Configuration=Release -p:TargetFramework=net45 de4dot.netframework.sln
if ($LASTEXITCODE) { exit $LASTEXITCODE }
Remove-Item Release\net45\*.pdb, Release\net45\*.xml, Release\net45\Test.Rename.*

dotnet publish -c Release -f netcoreapp2.1 -o publish-netcoreapp2.1 de4dot
if ($LASTEXITCODE) { exit $LASTEXITCODE }
Remove-Item publish-netcoreapp2.1\*.pdb, publish-netcoreapp2.1\*.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ public override void LoadServer(string filename) {
appDomain = AppDomain.CreateDomain(Utils.RandomName(15, 20));
thread = new Thread(new ThreadStart(() => {
try {
#if NET35
appDomain.ExecuteAssembly(filename, null, new string[] {
#elif NET45
appDomain.ExecuteAssembly(filename, new string[] {
#else
#error Unknown tfm
#endif
((int)serviceType).ToString(), ipcName, ipcUri
});
}
Expand Down

0 comments on commit b182d5d

Please sign in to comment.