Adding Project options

Topics: APIs, C# Language Design
Apr 29, 2014 at 10:09 PM
Hi.

I need to add project options (SyntaxRewriters) to be transmitted to CSharpParseOptions to be applied.
Problem is that we do not have CSharpProjectShimWithServices, nor CSharpLanguageService source code to do it (it should be in its BindToProject method).

How can I achieve that ?

Thanks.
May 5, 2014 at 3:37 PM
I finally answer my own question.
  1. Into MSBuildTasks, Csc.cs
    1.1. I added a public property.
    1.2. I oveerrided AddResponseFileCommands to append a switch for my new property to be given to the command line compiler.
  2. Into CscTaskFactory.cs
    2.1 In CreateTask, I split the received parameter on # character. First part is for VsSessionGuid, as before. Second part, if any, is to initialize my new Property.
  3. Into CompilerPackage.cs
    3.1. I changed <Task Evaluate=""true"" >$(VSSessionGuid)</Task> into <Task Evaluate=""true"" >$(VSSessionGuid)#$(MyProperty)</Task>
    3.2. Not all .targets file are changed this way. I had to had code at the end of initialize to change any .targets file in ImportsAfter directory to apply the same patch.
  4. Into CommadLineParser.cs
    4.1. I added a case for my new switch.
    4.2. I passed it to the CSharpParseOptions.
Now do whatever you want with this new option...
Marked as answer by ldubois on 5/5/2014 at 8:37 AM