error CS1056: Unexpected character '$' during code analysis

37 views Asked by At

When I am running the build in C# code analysis from the command line with msbuild on some code I get:
(CoreCompile target) -> SLIP.cs(10,51): error CS1056: Unexpected character '$' [....Libraries.Utils.Protocol.Slip.csproj]

This is the minimal code that cause the problem:

using System;
namespace Libraries.Utils.Protocol.Slip
{
    public static class SLIP
    {
        public static byte[] AttachFrame(byte[] data)
        {
            // Declare buffer:
            byte[] buffer = null;
            throw new ArgumentOutOfRangeException($"{System.Reflection.MethodBase.GetCurrentMethod().Name}: Input data must be a non-empty byte array.");
            return buffer;
        }
    }
}

Removing the $ resolves the the error. What is the problem and how do I resolve the error. It is not in the rule file.

A hex editor shows nothing weird in the code.

0

There are 0 answers