Sublime Forum

New plugin: CompleteSharp (C# code completion)

#1

github.com/quarnster/CompleteSharp

0 Likes

#2

I want to thank you for this plug-in :smile:

I’m not using C# at the moment, but it’s good to know that someone has taken an interest for ST.

Andy.

0 Likes

#3

This is AWESOME!
i have installed this plugin and it help me a lot.

but i found that it does not support generic class.

ArrayList list = new ArrayList();
list.   <= it show correct suggestions.
List<Foo> list = new List<Foo>();
list.  <= it doesn't show any reasonable suggestions.
0 Likes

#4

Correct, generics are not supported at the moment. Filed as issue #3

0 Likes

#5

You sir have made my day/week/month/year.
I guess it’s time to try and get a mono build system setup in ST2 and do away with monodevelop from my toolchain completely :smile:.

0 Likes

#6

Haven’t been able to get this plugin to complete anything for me yet. On windows: I’ve installed .NET, Mono, and the Windows 7 SDK. I can do command line builds and mono works just fine. When I create a string and try to get a completion it just says no completions available.

if I type:

string s = "foo"; s.

The console shows

46, 16, u'string', u's', u'.') absolute is ArcaneArcade.Procedural2d.Common.Point (6.000042 ms) ArcaneArcade.Procedural2d.Common.Point.string =
And I get “no available code completion”

Right now my “completesharp_assemblies” is blank… but for fun I added the path to my mscorelib.dll (“D:\Program Files (x86)\Mono-2.10.8\lib\mono\4.0\mscorlib.dll”) to see if it just wasn’t finding it. That caused Sublime to go non responsive.

Anyone have any pointers to setting up completesharp? I’m pretty sure I’ve just got something configured wrong.

I did make a package to build monodevelop projects though:
github.com/rstehwien/Sublime-MonoDevelop

0 Likes

#7

Try this and this, but replace -complete;;–;;Bar with -complete;;–;;System.String. Could you open up a new issue at the github page with the output of these experiments and point me to the exact source code you’re using?

0 Likes

#8

Thanks for the tips. I’ll try them tonight and open up the issue.

0 Likes

#9

It started working… my best guess is that cleaning up my %path% and rebooting the machine fixed things. I still have D:\Program Files (x86)\Mono-2.10.8\lib\mono\4.0\mscorlib.dll" in my completesharp_assemblies. Maybe it was finding multiple assemblies from .NET and Mono. No idea.

0 Likes

#10

Very nice plugin! However, I seem to be having the same problem that’s described in Issue #6 (adding my own assemblies breaks the standard completion) on Mac OSX 10.8.6. I’ve updated via package manager, so I presume I have the latest build. Am I missing something?

0 Likes

#11

Is there anything printed in the python console? What do you mean with “breaking the standard completion”? Does completion for your added assemblies work but not for the standard library types such as string? Btw, you’ve got a much higher chance of me seeing issues by filing one on github rather than writing about it here.

0 Likes

#12

Sorry, I didn’t want to open a duplicate of an issue that already appears to have been resolved. I’m assuming it’s something I’m configuring incorrectly, but I can certainly open something on github if you’d prefer. For the time being, though…

Without any custom assemblies, autocomplete works as expected. When I add my assemblies, autocomplete works for them, but stops working for the standard libraries.

 "completesharp_assemblies": 
        "/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll",
        "/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.dll"
        ],
using UnityEngine;
using System.Collections;

public class Test {
	System.
}

Console shows this for normal, no-custom-assembly (working) attempt to autocomplete "System."
(-1, -1, u’System’, None, u’.’)
stderr: got: -findclass;;–;;System
stderr: Exception: An empty file name is not valid.
stderr: at System.IO.FileSystemInfo.CheckPath (System.String path) [0x00000] in :0
stderr: at System.IO.FileInfo…ctor (System.String fileName) [0x00000] in :0
stderr: at (wrapper remoting-invoke-with-check) System.IO.FileInfo:.ctor (string)
stderr: at CompleteSharp+MyAppDomain.CheckUpdate () [0x00000] in :0
stderr: execute args: -findclass
stderr: execute args: System
stderr: Trying UnityEngine.System
stderr: Trying System.Collections.System
stderr: Trying System.System
stderr: Trying System
stderr: System
absolute is System (3.395081 ms)
finding what to complete took 0.004053 ms
completing System.
stderr: got: -complete;;–;;System;;–;;
stderr: Exception: An empty file name is not valid.
stderr: at System.IO.FileSystemInfo.CheckPath (System.String path) [0x00000] in :0
stderr: at System.IO.FileInfo…ctor (System.String fileName) [0x00000] in :0
stderr: at (wrapper remoting-invoke-with-check) System.IO.FileInfo:.ctor (string)
stderr: at CompleteSharp+MyAppDomain.CheckUpdate () [0x00000] in :0
stderr: execute args: -complete
stderr: execute args: System
stderr: execute args:
completion took 215.743065 ms
total 219.970942 ms

When I add the above assemblies, the same attempt yields:
(-1, -1, u’System’, None, u’.’)
stderr: Loading: /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll
stderr: Loading: /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.dll
stderr: got: -findclass;;–;;System
stderr: execute args: -findclass
stderr: execute args: System
stderr: Trying UnityEngine.System
stderr: Trying System.Collections.System
stderr: Trying System.System
stderr: Trying System
stderr: Exception: The classes in the module cannot be loaded.
stderr: at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
stderr: at System.Reflection.Assembly.GetTypes () [0x00000] in :0
stderr: at CompleteSharp+MyAppDomain+Hack.Execute (System.String] args, System.Collections.ArrayList modules) [0x00000] in :0
absolute is Test (529.119968 ms)
stderr: got: -returntype;;–;;Test;;–;;System
stderr: execute args: -returntype
stderr: execute args: Test
stderr: execute args: System
stderr: Exception: The classes in the module cannot be loaded.
stderr: at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
stderr: at System.Reflection.Assembly.GetTypes () [0x00000] in :0
stderr: at CompleteSharp+MyAppDomain+Hack.Execute (System.String] args, System.Collections.ArrayList modules) [0x00000] in :0
Test.System =

0 Likes

#13

Thanks I can reproduce this. Looking into it now.

0 Likes

#14

derthnada, try upgrading to version 1.0.8 which should behave much better.

The root cause was that UnityEditor.dll had dependencies that weren’t loaded and thus throwing an exception when trying to call GetTypes on that assembly. This exception has now been wrapped in a try-catch block. I also made ResolveAssembly a little smarter in that it tries to look for assemblies in the same path of other assemblies loaded.

If you want to get completion of UnityEditor, you just need to add in the full path of UnityScript.dll (which is in a different path compared to the other already loaded dlls) to the ones you already have in there and it seemed in my testing to be able to resolve everything else needed by itself.

0 Likes

#15

That works perfectly. Thanks so much for looking into this!

0 Likes