I'm looking at a way to fix this, but encoding handling looks messy. It seems like not all paths even handle encoding (processing from file names does to some degree, but processing from Cin does not at all). It looks like that part needs a refactoring.
Incorrect indentation of C# in UTF8+BOM file starting with preprocessor macro
I attach an improved patch, that does not fail any unit tests. Also a patch adding new unit test.
I attach a patch with a workaround. isInClassInitializer was not reset at end of statement.
Incorrect indentation of C# templated function declaration
Incorrect indentation of C# collection initialization