Water editor try/finally block default formatting

In Water C# code, when the file is reformatted (Edit -> Reformat File), I think the finally blocks are indented incorrectly (at least different than the catch blocks).

This is what I get after a reformat:

            try
            {
                
            }
            catch(Exception e)
            {
                
            }
            
            try
            {
                
            }
            finally
                {
                
                }

Does that happen in any context? or can you give me a complete file as tetscase? thanx!

Thanks, logged as bugs://81437

Yes, seems to happen in any context. The indenting happens correctly initially while typing and adding the curly braces, but if something signals a reformat, or if you choose it from the edit menu, the finally curlys get indented more.

Water test case:

File -> New Project -> Echos -> Winforms

Then modify Program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace WindowsApplication
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += OnThreadException;
            using (MainForm lMainForm = new MainForm())
            {
                Application.Run(lMainForm);
            }
            
            try
            {
                // try something
            }
            catch (Exception e)
            {
                // oops
            }
            
            try
            {
                // do something else
            }
            finally
            {
                // done with something else
            }
            
        }

        void OnThreadException(Object sender, ThreadExceptionEventArgs e)
        {
            System.Windows.Forms.MessageBox.Show(e.Exception.Message);
        }
    }
}

Then go to Edit -> Reformat File, and you will get this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace WindowsApplication
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += OnThreadException;
            using (MainForm lMainForm = new MainForm())
            {
                Application.Run(lMainForm);
            }
            
            try
            {
                // try something
            }
            catch (Exception e)
            {
                // oops
            }
            
            try
            {
                // do something else
            }
            finally
                {
                    // done with something else
                }
            
        }

        void OnThreadException(Object sender, ThreadExceptionEventArgs e)
        {
            System.Windows.Forms.MessageBox.Show(e.Exception.Message);
        }
    }
}
1 Like

glad the editing part is fine, coz that’s my code in water ;). the reformat is done my the manager project system, and that’s out of my hand to fix or worry about ;).

ps: some new editor features in 2345. let me know what you think!

I can’t seem to figure out what the new features are. Hints please?

for example, type “if”.

1 Like

Nice!!!

1 Like

Hello,
I couldn’t reproduce the problem with reformatting here. Two weeks ago I had that bug logged, and I fixed it on Nov 9. So if you have the earlier build, could you please download latest and check with it. If you’ve got recent up-to-date elements, please give me some video on how you are reproducing the problem.
Thanks in advance.

Hi,

In the latest build it isn’t happening with just comments inside the finally block, so you probably aren’t seeing the problem there.

Try following the steps in my original post, but paste this in instead:

            try
            {
                Application.Run();
            }
            catch (Exception e)
            {
                Application.Run();
            }
            
            try
            {
                Application.Run();
            }
            finally
            {
                Application.Run();
            }

After going to Edit -> Reformat File the final curly brace will indent itself too far. Curiously enough, the first curly brace in the finally block stays put now.

Let me know if that doesn’t show the problem for you and I will try to figure out how to do a video of some sort.

Yes, reproduced with your testcase now.
Thanks.

1 Like

bugs://81437 got closed with status fixed.