botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Azure Bot Service, C#]Can not compile C# 7 syntax

Open sposaro opened this issue 9 years ago • 6 comments

I'm not able to compile on Azure, but I can compile locally. The errors I'm getting are because Azure doesn't understand the new C# syntax. I'm getting error for inline getters and setters as well as errors for pattern matching in my case statements.

Is there a way to update my Azure resource?

EX: private string _name; public string Name { get => _name; // Error here set => _name = value; // Error here }

switch(myObj) { case Interface1 i : // error here break; case Interface2 i : // error here break; }

sposaro avatar Nov 21 '17 18:11 sposaro

@sposaro You are using lambda expressions on getters and setters. getter lambda expression supported since C#6, setter lambda expression is added in C#7 make sure to set your azure app service to c#7 if supported by Azure.

msmohan avatar Nov 21 '17 19:11 msmohan

Hi @sposaro

Great question!

Azure Functions use a very recent version of Roslyn, and C#7 syntax should work without issue. What is the rest of your code?

Here is an example:

image

EricDahlvang avatar Nov 21 '17 21:11 EricDahlvang

@EricDahlvang I just sent you an email with an actual code snippet along with the error logs. However, it clear doesn't not like the new pattern matching syntax or the inline setters.

@msmohan I'm not sure where that setting you speak of is. Am I looking in the correct place. image

sposaro avatar Nov 22 '17 01:11 sposaro

@sposaro Are you getting CS1043 and CS1513 errors, as shown below?

image

msmohan avatar Nov 27 '17 23:11 msmohan

@EricDahlvang and I looked into this.

As a workaround you can update the following references to its latest version in order to make lambda expressions to work on C#7.

  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform ver: 2.4.0
  • Microsoft.Net.Compilers ver: 1.0.8

This is discussed here at project Kudu

We can repro this issue on WEB and LOCAL and we will escalate the issue with Azure Support team. image

msmohan avatar Nov 28 '17 02:11 msmohan

Closing this, since it is not directly related to the Bot Framework, we have a workaround, the root cause has been found and escalated to the responsible team.

EricDahlvang avatar Dec 05 '17 20:12 EricDahlvang