Unable to write function element with expression

NOTE. . This seems to be a problem with the compiler that was used with SSDT projects, apparently it was fixed in RC 2017. My problem is similar to that described here.

I have code that does not allow me to write it as a member of a function with an expression. In short, I want to do this:

void foo() => bar();

But the IDE throws a tantrum and requires me to write it like this:

void foo() { bar(); }

I mean, these are two extra characters, but I'm not sure why he complains, the errors also make no sense. This gives me the following 3 errors:

  • CS0000 :; Expected,
  • CS0000: The method must have a return type.
  • CS0000: ID expected.

The full code is as follows.

public static void foo() => bar("some param"); // Errors on this line.
static void bar(string myParam) { //20 lines of code } 

#, . .

VS 2015 4.6.1

:

using System.Data.SqlClient;
using Microsoft.SqlServer.Server;

public partial class Triggers
{

    private const string ConnectionString = "context connection = true";

    private const string ReadInsertedTable = @"
    SELECT ID,
           (
               SELECT *
               FROM inserted AS b
               WHERE a.ID = b.ID
               FOR XML RAW, ELEMENTS XSINIL
           )
    FROM inserted AS a
";
    [SqlTrigger(Name = "Person_Insert", Target = "Person", Event = "FOR INSERT")]
    public static void Person_Insert() => AuditInsert(TableName); //  All errors here.

    private const string TableName = "Person";

    private static void AuditInsert(string tableName)
    {

        using (var readConnection = new SqlConnection(ConnectionString))
        using (var writeConnection = new SqlConnection(ConnectionString))
        {
            using (var readCommand = new SqlCommand(ReadInsertedTable, readConnection))
            {
                readConnection.Open();
                using (var reader = readCommand.ExecuteReader())
                {
                    SqlContext.Pipe.Send((reader));
                }
            }
        }
    }
}

enter image description here

: msbuild, Visual Studio.

+4
2

- . :

Non-: https://dotnetfiddle.net/LJm1Fj

: https://dotnetfiddle.net/aMUsj0

, - Visual Studio, VS2015 Roslyn .

:

  • , *.csproj, ToolsVersion <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • Output- > Build VS , : C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:\Program Files (x86)\Reference ... Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\bin
  • , .NET VS
+3

.

, rocky , SQL Server (.sqlproj) ( .csproj) # 6.0, , Visual Studio 2015. , , SQL Server, .


:

:

private const string TableName = "Person";

. tableName AuditInsert.

0

Source: https://habr.com/ru/post/1668789/


All Articles