Author Topic: C# Beautify problem  (Read 5879 times)

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
C# Beautify problem
« on: June 06, 2017, 12:34:33 PM »
Hello,

I'm currently evaluating Slickedit 2016 v21.0.3.0 x64 and having trouble finding the right beautify option to get my desired layout.

I want this:

if (InvokeRequired)                                     
{                                                       
   BeginInvoke(new EventHandler(OnMatchingSpeedChanged),
                       new object[] { sender, e });             
}                                                       

but keep getting this:

if (InvokeRequired)                                     
{                                                       
   BeginInvoke(new EventHandler(OnMatchingSpeedChanged),
                       new object[]
  { sender, e });             
}

i.e., I want new object[] { sender, e } to stay on one line

Also, puzzled why there isn't an Allman option for C# as there is for C++?
« Last Edit: June 06, 2017, 12:50:06 PM by wolfie »

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #1 on: June 06, 2017, 01:06:49 PM »
Side question, if it proves impossible to get Slickedit's beautify engine to work as I want, is there a way to use Astyle instead from within Slickedit?

http://astyle.sourceforge.net/

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: C# Beautify problem
« Reply #2 on: June 06, 2017, 03:15:39 PM »
This looks like a bug to me, there isn't and shouldn't be a setting to make it format the code that way.  I'll take a look at it.

Now that you mention it, I don't think there's a good reason not to have Allman; or something close to Allman that matches how Microsoft formats C# in documentation.  Not sure that it has a name more recognizable than Allman.  I'll put that on the list to add for the next release.

For external beautifiers, the easiest thing you can do is put together a macro to beautify an entire buffer.  For example, the docs indicate that astyle can read from stdin and write beautified output to stdout, so you can use the filter_command() function to use astyle to update the
current buffer:

Code: [Select]
#include "slick.sh"
#import "fileman.e"
#import "util.e"

_command void astyle_buf() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   _save_pos2(auto saved);
   select_all();
   filter_command('astyle --style=allman');
   _restore_pos2(saved);
}

If you put that in a file called "test.e" and then run "load some/path/test.e" at the SlickEdit command line, the 'astyle_buf' command will be available for you to either run manually at the command line, or bind to a keypress.

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #3 on: June 06, 2017, 03:22:57 PM »
Thanks. As a slickedit newbie I was reluctant to call it a bug, but that was in fact my private belief because I went through pretty much every option and none had any effect as far as I could see.

Might it be related to this previous issue?
https://community.slickedit.com/index.php/topic,14930.0.html

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: C# Beautify problem
« Reply #4 on: June 06, 2017, 05:32:08 PM »
Should it be called Microsoft?

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: C# Beautify problem
« Reply #5 on: June 06, 2017, 06:21:44 PM »
If you're interested in trying out a fix for the brace problem, let us know what OS you're running on.

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #6 on: June 06, 2017, 06:59:33 PM »
I'm getting this behaviour under Win7 x64 & Win10 x64.
« Last Edit: June 06, 2017, 09:04:05 PM by wolfie »

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #7 on: June 07, 2017, 07:14:28 PM »
Any news? Happy to try out a fix on Windows (x64).

-- wolfie

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: C# Beautify problem
« Reply #8 on: June 07, 2017, 07:18:17 PM »
You should have a PM with instructions on how to get the test fix.   Do you have anything show up if you go to "My Messages" on this page?

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #9 on: June 07, 2017, 08:37:15 PM »
No, I have just checked, there are no PM messages at all.

SlickEdit Support

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 384
  • Hero Points: 29
Re: C# Beautify problem
« Reply #10 on: June 07, 2017, 08:52:48 PM »
Message sent.

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #11 on: June 07, 2017, 09:39:53 PM »
Thank you, I can confirm that fixed my C# beautify problem!

-- wolfie

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #12 on: June 17, 2017, 08:33:24 AM »
How would I go about porting the C++ Allman profile for use with C#? Is porting a profile even possible?

Alternatively, does anyone have a C# Allman profile they could share?
« Last Edit: June 18, 2017, 10:11:04 AM by wolfie »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: C# Beautify problem
« Reply #13 on: June 19, 2017, 12:36:23 PM »
They're almost copyable between the languages, the catch is the C# specific options. 

Not sure if it will happen today, but I can do a port and provide an export that you can import into your configuration.

wolfie

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: C# Beautify problem
« Reply #14 on: June 19, 2017, 12:50:05 PM »
Thanks, that would be great.

Does that mean porting a profile is internal to slickedit and not easy/possible for the user?