Closed burberger closed 2 years ago
I see no problems to allow customization of the pdb generation.
Though I would like to understand the problem you are solving.
I have attached the sample that shows how to debug the script. It seems to work just fine with DebugInformationFormat.PortablePdb
A rough version of what I'm doing:
CSScriptLib.CSScript.EvaluatorConfig.Access = EvaluatorAccess.Singleton;
CSScriptLib.CSScript.EvaluatorConfig.DebugBuild = true;
CSScriptLib.CSScript.Evaluator.CompileAssemblyFromFile(filename, asm_name);
var asm = Assembly.LoadFile(asm_name);
CSScriptLib.CSScript.Evaluator.ReferenceAssembly(asm);
I'm loading a set of user provided script files and then subsequently registering methods from them into my runtime. When I load them in this way, the PDB file reference appears to be looking for a file which contains the internal assembly name containing a GUID instead of the name matching the PDB on disk. Because that internal name contains *, I can't actually make things match exactly as far as I'm aware. Changing the debug info format to embedded ended up being the best answer I could come up with without doing more substantial changes to the code, but this may be a result of me not being super familiar with how the .net debug infrastructure works.
I'll put up the PR a bit later, thanks Oleg!
I see. So it is about referencing the script assembly but not the script assembly being executed. Not a problem. You are just in time for the new release. :)
Done. 9209e8498fd200d4dee2650df35bf2d94c743e89
Will be released in a day or two.
CSScript.EvaluatorConfig.PdbFormat = DebugInformationFormat.Embedded;
Awesome, thanks again Oleg!
Not a problem. Will publish nuget tonight
done
Thank you, I have merged the PR. Indeed it was a mistake to load the pdb when Embedded
format is selected.
Can you please check the package before I publish it: https://github.com/oleg-shilo/cs-script/releases/tag/v4.4.1.0
Tested, works as intended.
Excellent. Txs.
Published on nuget.org. Give it a few mins to get indexed and you can import the new release to your codebase it properly.
I'm using CSScriptLib in my project, and I wanted to enable debugging of the scripts loaded into the program. The simplest way I've found to do this is to change https://github.com/oleg-shilo/cs-script/blob/master/src/CSScriptLib/src/CSScriptLib/Evaluator.Roslyn.cs#L424 to use
DebugInformationFormat.Embedded
so the PDBs get loaded automatically without manually associating them with the assembly viaAssembly.Load
, which breaks the Roslyn loader.My thought is that this could be added to EvaluatorConfig and the debug information format be made controllable by the user. I'd be happy to submit a PR with this if you think this is a reasonable approach.