Posted 2 years ago by Bill Rokos
Version: 16.1.0203
Avatar

Hi

I'm trying to get intellisense to work with c# and partial classes. I did a someone trying to accomplish what I'm trying to do in this post here 101241. However, when I added my partial class using project.SourceFiles.QueueCode, my intellisens broke.

As an example, i'm using the sample demo that comes with the installer DotNetAddonCSharpGettingStarted02 with some modifications.

MainControl.xaml, i changed the class to be partial class and removed the using System.Collections.Generic;

...

<system:String xml:space="preserve">using System;

namespace DotNetLanguagesAddon {
 
	public partial class CSharpLanguage {

...

 

MainControl.xaml.cs, i added my custom partial class to the queue

public MainControl() {
     InitializeComponent();
					
      projectAssembly = new CSharpProjectAssembly("SampleBrowser");
      var assemblyLoader = new BackgroundWorker();
      assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader;
      assemblyLoader.RunWorkerAsync();

      var language = new CSharpSyntaxLanguage();
      language.RegisterProjectAssembly(projectAssembly);
      codeEditor.Document.Language = language;

      // my custom class
      projectAssembly.SourceFiles.QueueCode(language, "myclass.cs", @"using System;
namespace DotNetLanguagesAddon {
  public partial class CSharpLanguage {
    protected string Name { get; set; }    
  }
}");  
    }

 

When I run the editor, I get the following intellisense results in the CSharpLanguage class:

  • this.Name Works
  • any intellisense from using System; DOES NOT work. ie: var dt = new DateTime();
  • if I add using System.Collections.Generic to the code, intellisens for this does not work. ie: var mylist = new List<string>();

The result above are only applicable in the CSharpLanguage class, if i create a new class and start typing in there, the intellisense works just fine.

Is there some method i'm missing to have the intellisense work correctly for related partial classes?

Comments (19)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

I just tested all of the above in our latest local 2016.1 build with the changes you mentioned and all the IntelliPrompt is showing up correctly for me.  Are you sure you're on the latest build? Although I'm not sure anything has changed in this area recently.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Oh sorry about that, my example code for myclass.cs is incorrect. It should be without the using System. Now can you retry it? The intellisense should be broken.

      // my custom class
      projectAssembly.SourceFiles.QueueCode(language, "myclass.cs", @"namespace DotNetLanguagesAddon {
  public partial class CSharpLanguage {
    protected string Name { get; set; }    
  }
}");    

[Modified 2 years ago]

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

Can you tell me exactly what code is in the editor and maybe put a | where the caret should be when you are testing?  I still don't really see anything wrong when testing on our end.  Assuming "mylist" is defined as you said in the method in the editor, it won't show IntelliPrompt since your removed "using System.Collections.Generic;" but it does if you put that back in.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Giving the custom class:

      // my custom class
      projectAssembly.SourceFiles.QueueCode(language, "myclass.cs", @"namespace DotNetLanguagesAddon {
  public partial class CSharpLanguage {
    protected string Name { get; set; }    
  }
}");    

 I have the following on my editor. Caret location 1 doesn't work as intended, while 2 works.

using System;

namespace DotNetLanguagesAddon {
  public partial class CSharpLanguage {
 
    public void DemoTest() {
      var number = 1;
	Console.WriteLine(number.ToString());
	var d = new Dat| /*<strong>My caret location 1</strong> */
        /* As i'm typing "new Dat", the IntelliPrompt shows up but DateTime doesn't show in the list */
    }
  }
 
  public class Dude {
    public Dude() {
      var d = new Dat| /* <strong>My caret location 2</strong> */
      /* As i'm typing "new Dat", the IntelliPrompt shows up with DateTime in the list */
    }
  }    	
}

 The same applies for when i add using System.Collections.Generic;, caret 1 doesn't work and caret 2 works.

using System;
using System.Collections.Generic; 

namespace DotNetLanguagesAddon {
  public partial class CSharpLanguage {
 
    public void DemoTest() {
      var number = 1;
	Console.WriteLine(number.ToString());
	var l = new Lis| /* <strong>My caret location 1</strong> */
        /* As i'm typing "new Lis", the IntelliPrompt shows up but List doesn't show in the list */
    }
  }
 
  public class Dude {
    public Dude() {
      var l = new Lis| /* <strong>My caret location 2</strong> */
      /* As i'm typing "new Lis", the IntelliPrompt shows up with List in the list */
    }
  }    	
}
Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

Thanks, we were able to see it and track it down now.  The problem is that when there are partial classes, behind the scenes it makes a "merged" ITypeDefinition.  That ITypeDefinition like all others has a NamespaceDeclaration property.  However it currently returns the INamespaceDeclaration of the first merged type within it.  That logic is incorrect and needs to probably change the property to a method instead where we pass in the source key and location for the file being edited and it would do its best to find a matching merged type and return its INamespaceDeclaration instead.  This unfortunately isn't a quick or easy change though because it will force us to start tracking additional source key and location information for all types.  We are making notes about this and have added it onto the TODO list.  Right now we are working on wrapping up the 2017.1 beta and have to focus our development resources on that.  Once 2017.1 is fully released, please write back and we will revisit this and hopefully fix it for you.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Would there be a bug report somewhere I can subscribe to?

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

You can watch our Announcements forum for release notes but other than that, we'd likely post in this thread if we worked on it and resolved it.  Again, I'd urge you to write us back after 2017.1 is fully released and we can try and work on it at that time.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

I checked on the release notes for 2017.1 and it doesn't seem this bug fix is listed (or at least i didn't see it). Wanted to follow up and see if you guys have an ETA for this bug?

Thanks

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

We're starting to look into it now and are brainstorming some ideas in our Slack #uicontrols channel.  The fix for this might also indirectly allow support for Goto Definition type functionality in your apps, so trying to be smart about how we add it.


Actipro Software Support

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

I believe we have this fixed now for the next maintenance release.  If you'd like to try a preview build to verify the updates, please write our support address and mention this thread.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Hi,

So I just got the preview build and tested it out. The partial class issue I was having before seems to be fixed, cool.

However, I found a new bug with this partial class. After my custom class was added, if my class has a base class (inheritng class), the intellisense for the base class does not working.

Code behind used to add my custom partial class. Similar to above, but changed the namespace a bit

  // my custom class
  projectAssembly.SourceFiles.QueueCode(language, "myclass.cs", @"
namespace DotNetLanguagesAddon.Main {
  public partial class CSharpLanguage {
    protected string Name { get; set; }    
  }
}");    

 Code in the editor. Main difference is the name space and the base class MyBaseClass where full name is DotNetLanguagesAddon.Services.MyBaseClass

using System;
using DotNetLanguagesAddon.Services;
 
namespace DotNetLanguagesAddon.Main {
  public partial class CSharpLanguage: MyBaseClass {
    // intellisense for MyBaseClass DOES NOT work
  }
 
  public class Dude: MyBaseClass  {
    // intellisense for MyBaseClass WORKS  
  }    	
}

 The intellisense for MyBaseClass in CSharpLanguage will work if I write the full class name out:

C#using System;
using DotNetLanguagesAddon.Services;
 
namespace DotNetLanguagesAddon.Main {
  public partial class CSharpLanguage: DotNetLanguagesAddon.Services.MyBaseClass {
    // intellisense for MyBaseClass WORKS
  }
 
  public class Dude: MyBaseClass  {
    // intellisense for MyBaseClass WORKS  
  }    	
}

Could you look into this?

Thanks

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

Thanks for reporting this scenario.  I believe we have a fix in place for it for the upcoming maintenance release.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Hi,

Thanks for the fast reply.

 

Is there anyway I can get a hold of this before the official release to test? The build i was testing was 17.1.0211

 

Thanks

 

EDIT: fixed version number

[Modified 2 years ago]

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

I believe we emailed you yesterday with a link to a preview build at the private ticket we last communicated on.  Did you receive that?


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Hi,

Yes, I go the beta build which i'm using to test. As I mentioned, the initial problem I had was fixed in the beta build, but it cause the intellisense for the base class to not work after adding the partial class.

Here is some code I'm running to get the DLL version i'm using

ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor syntaxEditor = this.Editor;
var info = syntaxEditor.GetType().Assembly.FullName;

Info returns: "ActiproSoftware.SyntaxEditor.Silverlight, Version=17.1.211.0, Culture=neutral, PublicKeyToken=f5ebeca6de33c9f3"

I'm assuming the above is the latest beta build version?

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

After you submitted this new issue early yesterday, we posted a new preview build (same build number though).  Did you download that?  We had emailed you about it last night.  That latest build has the update for the most recently reported issue.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Sorry, I didn't get it. Can you please resend it.

Thank you

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

I just resent it.  If you don't receive it, please check your mail server's spam folder.


Actipro Software Support

Posted 2 years ago by Bill Rokos
Avatar

Thanks, the new preview build fixed this.

The latest build of this product (v2018.1 build 0232) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.