Skip to content

Commit 9ed0764

Browse files
committed
use pdbpath from TryOpenAssociatedPortablePdb
1 parent 2118d87 commit 9ed0764

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

NetcodePatcher/CodeGen/CompiledAssemblyFromFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public CompiledAssemblyFromFile(string assemblyPath)
2828
}
2929

3030
public bool DebugSymbolsAreEmbedded { get; private set; }
31+
public string? PortableDebugSymbolsFilePath { get; private set; }
3132

3233
public string Name => Path.GetFileNameWithoutExtension(_assemblyPath);
3334
public string[] References { get; set; } = Array.Empty<string>();
@@ -54,6 +55,7 @@ public byte[] ReadPdb(FileStream peStream)
5455
else
5556
{
5657
Log.Information("Found debug info : ({PdbFileName})", Path.GetFileName(pdbPath));
58+
PortableDebugSymbolsFilePath = pdbPath;
5759
}
5860

5961
return pdbReader.ReadAllBytes();

NetcodePatcher/CodeGen/NetcodeILPPApplicator.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public NetcodeILPPApplicator(string assemblyPath, string outputPath, string[] re
2929
private string AssemblyName => Path.GetFileNameWithoutExtension(AssemblyPath);
3030
private string AssemblyFileName => Path.GetFileName(AssemblyPath);
3131
private string AssemblyDirName => Path.GetDirectoryName(AssemblyPath)!;
32-
private string PdbPath => Path.Combine(AssemblyDirName, $"{AssemblyName}.pdb");
3332

3433
public static bool HasNetcodePatchedAttribute(ICompiledAssembly assembly)
3534
{
@@ -63,6 +62,7 @@ public void ApplyProcesses()
6362
}
6463

6564
var debugSymbolsAreEmbedded = assemblyFromFile.DebugSymbolsAreEmbedded;
65+
var pdbPath = assemblyFromFile.PortableDebugSymbolsFilePath;
6666
ICompiledAssembly assembly = assemblyFromFile;
6767

6868
if (HasNetcodePatchedAttribute(assembly))
@@ -81,7 +81,7 @@ public void ApplyProcesses()
8181
// remove files with _original.dll and _original.pdb
8282

8383
renameAssemblyPath = Path.Combine(AssemblyDirName, $"{AssemblyName}_original.dll");
84-
renamePdbPath = Path.Combine(AssemblyDirName, $"{AssemblyName}_original.pdb");
84+
renamePdbPath = Path.Combine(Path.GetDirectoryName(pdbPath)!, $"{Path.GetFileNameWithoutExtension(pdbPath)}_original.pdb");
8585

8686
if (File.Exists(renameAssemblyPath))
8787
{
@@ -96,8 +96,8 @@ public void ApplyProcesses()
9696
}
9797

9898
File.Move(AssemblyPath, renameAssemblyPath);
99-
if (!debugSymbolsAreEmbedded)
100-
File.Move(PdbPath, renamePdbPath);
99+
if (pdbPath is not null)
100+
File.Move(pdbPath, renamePdbPath);
101101
}
102102

103103
ICompiledAssembly ApplyProcess<TProcessor>(ICompiledAssembly assemblyToApplyProcessTo)
@@ -167,10 +167,10 @@ ICompiledAssembly ApplyProcess<TProcessor>(ICompiledAssembly assemblyToApplyProc
167167
File.Move(renameAssemblyPath!, AssemblyPath);
168168
}
169169

170-
if (File.Exists(renamePdbPath!))
170+
if (pdbPath is not null && File.Exists(renamePdbPath!))
171171
{
172-
if (File.Exists(PdbPath)) File.Delete(PdbPath);
173-
File.Move(renamePdbPath!, PdbPath);
172+
if (File.Exists(pdbPath)) File.Delete(pdbPath);
173+
File.Move(renamePdbPath!, pdbPath!);
174174
}
175175
}
176176

0 commit comments

Comments
 (0)