0

I am currently working on a proof of concept to assess if we can use Roslyn to

  1. compile a piece of C# code
  2. generate the appropriate PDB file that can be used to debug the assembly

So far I have been able to

  1. compile the c sharp code and load it in memory for execution
  2. create a PDB file

However I am not able to step in the C# code using the PDB file using VS 2013.

Does anyone has a sample code that can generate a PDB file that can be used for debugging?

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • I am trying to do the same thing on Linux. Roslyn for Windows Visual Studio 2015 and Monodevelop-Xamarin-Studio differs from Roslyn for Linux. Could you try either 1. step into your C# code using Monodeveloop or Xamarin Studio IDE - Debugger or 2) step into your C# code using Visual Studio 2015? May I ask you for your advice on how to generate an appropriate PDB file that can be used to debug the assembly on LInux with the csc.exe /debug or alternative swtich? I can help you with Monodevelop and Xamarin Studio. so feel free to ask me questions. Thank you very much. – Frank Oct 30 '15 at 16:21
  • Please look at this URL which could help answer your question, http://stackoverflow.com/questions/29084960/can-i-use-net-core-on-visual-studio-2013. Please have a niice weekend. – Frank Oct 30 '15 at 20:06
  • A simple sample C# HelloWorld program is all you need. – Frank Nov 01 '15 at 10:21
  • see sample code i am using to create the PDB file. Not sure it is correct though as i am not being able to use it for debugging. syntaxTree[0] = CSharpSyntaxTree.ParseText(sourceCode ); CSharpCompilation compilation = CSharpCompilation.Create( assemblyname, syntaxTrees: syntaxTree, references: refs, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, null, null, null, null, OptimizationLevel.Debug)); – user5453026 Nov 04 '15 at 14:42
  • May if the C# class ,CSharpCompilation you just mentioned is in the Roslyn or Monodevelop github project. How might we apply your idea to create a proof on conceot for setting breakpoints in pure .NET CoreCLR and CoreFX C# application programs compiled with Roslyn? Thank you. – Frank Nov 05 '15 at 05:04
  • May I ask if C# class ,CSharpCompilation you just mentioned is in the Roslyn or Monodevelop github project. How might we apply your idea to create a proof on conceot for setting breakpoints in pure .NET CoreCLR and CoreFX C# application programs compiled with Roslyn? Thank you. – Frank Nov 05 '15 at 09:49
  • I just tested System.Diagnostics.Break() on linux monodevelop? Does it require monodevelop integration with roslyn's new portable PDB? Thank you – Frank Nov 05 '15 at 14:32
  • I have been able to step in the assembly . to be able step in, you need to specify a file name whilst creating the syntax tree in this method.SyntaxFactory.ParseSyntaxTree(stringText, options, filename); – user5453026 Nov 06 '15 at 11:13
  • I am thinking of running an Linux test where I call the method SyntaxFactory.ParseSyntaxTree(string Test, options , filename = "Portable PDB file") in the monodevelop method CSharpImplementInterfaceService.cs – Frank Nov 06 '15 at 21:08
  • I am thinking of running an Linux test where I call the method SyntaxFactory.ParseSyntaxTree(string Test, options , filename = "Portable PDB file") in the monodevelop method inside CSharpImplementInterfaceService.cs named ImplementDisposePattern(Document document, SyntaxNode root, INamedType symbol, int position, bool explicitly). Thank you. – Frank Nov 06 '15 at 22:39
  • Please take a look at the latest pdb spec: https://github.com/Microsoft/microsoft-pdb Thank you. – Frank Nov 07 '15 at 12:43
  • here is an excellent article on a debugging compiler C# which uses abstract syntax tree titled, "A research C# compiler" Hanson, David R. ; Proebsting, Todd A. Software: Practice and Experience, 2004, Vol.34(13), pp.1211-1224 Could I email it to you? Thank you very much. – Frank Nov 09 '15 at 19:11
  • I am in the process of compiling again Monodevelop on Ubuntu Linux 14.04 LTS. We noticed that Monodevelop uses the Mono Debugger. Is there a way to change the debugger Monodevelop uses for C# pure .NET programs targeted for the Roslyn csc.exe compiler. Thank you. – Frank Nov 11 '15 at 05:29
  • I got this to work okay today and I can examiine C# variables now with the compilet string, INFO [2015-11-11 12:50:32Z]: /home/vowel/Desktop/roslyn/Binaries/Debug/csc.exe Thank you. – Frank Nov 11 '15 at 18:04

1 Answers1

0

You need to deploy the pdb file if you intend to debug the solution. If you are using a custom build step, it may be impossible to link the custom build step PDB file output with the Visual Studio 2013 debugger. The Roslyn team has not finished yet with connecting the Linux IDE breakpoint such as lldb and monodevlop with the new roslyn portable PDB specification. I am interested in rolling a proof of concept breakpoint demonstration. What specific books and articles should I read? Thank you.

Frank
  • 1,406
  • 2
  • 16
  • 42
  • I just succesfully tested C# language System.Diagnostics.Break() on linux monodevelop with Start Debugging? Does it require monodevelop integration with roslyn's new portable PDB? Thank you – Frank Nov 05 '15 at 14:30