Menu

#483 Indentation inside string

closed-fixed
string (2)
2023-04-01
2018-01-29
No

AStyle 3.1 will change the contents of strings during indentation.
public static string EnvSetup => $"{Unsetr} set PATH={string.Join(";", EnvironmentPaths)};%PATH%";
becomes
public static string EnvSetup => $"{Unsetr} set PATH={string.Join("; ", EnvironmentPaths)};%PATH%";
where there is an extra space added after the ";" in the middle of the string.

Discussion

  • André Simon

    André Simon - 2023-02-06
    • status: open --> open-accepted
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2023-02-09

    Hi, I know it is an old issue and maybe no longer relevant but which syntax supports this kind of strings? For astyle these are just two strings split by a single semicolon.

     
    • w-peuker

      w-peuker - 2023-02-09

      This is string interpolation in C#.
      https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated

      It was introduced in version 6.
      https://www.w3schools.com/cs/cs_strings_interpol.php

      Seemingly, interpolation can also be nested, see following examples:

      public class Test
      {
          public static void Main()
          {
              const string name = "World";
              // Simple C# String interpolation:
              Console.WriteLine($"Hello {name}!");
              // C# String interpolation with string literals embedded:
              Console.WriteLine($"Hello {"*"+name+"*"}!");
              // Recursive C# String interpolation:
              Console.WriteLine($"Hello {"*"+name+ $"{ name+name}" }!");
          }
      }
      

      See online demo https://ideone.com/9mzYUB

       

      Last edit: w-peuker 2023-02-09
      • w-peuker

        w-peuker - 2023-02-09

        (deleted)

         

        Last edit: w-peuker 2023-02-09
  • André Simon

    André Simon - 2023-02-09

    OK now I got it

     
  • André Simon

    André Simon - 2023-03-05

    You can test a fix in the latest 3.2 beta 3 release.

     
  • André Simon

    André Simon - 2023-04-01
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.

Auth0 Logo