Skip to content

Reindent problem with C# #168

Description

@stephen147

I assume that this controls the indentation for .ps1 files so hopefully, this is the correct place to post this issue.

With Powershell I have this code:

Function Get-ForegroundWindow {
  Add-Type @"
  using System; using System.Runtime.InteropServices; public class ClassGetForegroundWindow {
    [DllImport("user32.dll")]
    public static extern IntPtr GetForegroundWindow();
  }
"@
  return [ClassGetForegroundWindow]::GetForegroundWindow()
}

Get-ForegroundWindow

After reindenting it it appears to be:

Function Get-ForegroundWindow {
  Add-Type @"
  using System; using System.Runtime.InteropServices; public class ClassGetForegroundWindow {
    [DllImport("user32.dll")]
    public static extern IntPtr GetForegroundWindow();
  }
  "@
  return [ClassGetForegroundWindow]::GetForegroundWindow()
}

Get-ForegroundWindow

This then fails to run as the "@ is indented when it shouldn't.

Activity

  1. keith-hall commented on May 13, 2021

    @keith-hall
    Member

    I guess this repo lacks any tmPreferences files controlling indentation, so it uses the defaults. You'd want a unindentedLinePattern matching "@ iirc.

  2. stephen147 commented on May 13, 2021

    @stephen147
    Author

    Oh, I didn't even think to see if there was one. I assumed there was.

    Hopefully, this could get added as a rule if the person maintaining this repo sees this as it would be nice to be included out of the box.

  3. keith-hall commented on Dec 21, 2024

    @keith-hall
    Member

    Once #165 is merged and released, we will be able to officially close this issue as fixed 🎉

  4. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions