1

I'm trying to compile a standalone C# file using the Microsoft.CSharp.CSharpCodeProvider in mscorlib version 4.

It's complaining about properties that are using expression bodies instead of statement bodies.

I.e., this it will compile:

protected Foo MyFoo
{
    get { return this.myFoo; }
}

But this it won't:

protected Foo MyFoo => this.myFoo;

Is there a more recent version of mscorlib I should be using?

Jeff Dege
  • 11,190
  • 22
  • 96
  • 165
  • Can you include the code used to compile the file? – Camilo Terevinto Dec 14 '17 at 23:13
  • Also, did you look at this? https://stackoverflow.com/questions/32769630/how-to-compile-a-c-sharp-file-with-roslyn-programmatically – Camilo Terevinto Dec 14 '17 at 23:18
  • Pretty sure `CSharpCodeProvider` is severely deprecated. You should probably look to a roslyn based solution. – Kirk Woll Dec 14 '17 at 23:29
  • System.CodeDom always uses the installed version of the framework and uses the C# compiler that is stored in the framework directory (normally c:\windows\microsoft.net\framework\v4.0.30319). Just type "csc.exe" from the command line, it explicitly tells you which C# version it supports in its sign-on message. That still doesn't say anything about the version on your user's machine. But assuming you target at least 4.5 in your project, that will always be C# version 5. Feature, not a bug, you don't have to worry about deploying Roslyn to the user's machine. There is a Nuget package. – Hans Passant Dec 14 '17 at 23:33

0 Answers0