JavaScript Parser generate function descriptions argument descriptions from xml documentation files

Is it possible to use the xml documentation files for classes when autogenerating intellisense information?
I want the intellisense in the javascript editor to ise this imformation for a better user experience

Hi Derek,

Yes, this should be possible.
You should add your assemblies with HostItemOptions.GenerateDescriptions option to the HostItemsConfiguration, then it will try to locate XML documentation file based on assembly location, framework reference paths, or custom path specified by the following property.

Alternet.TsTypedefsGenerator.Core.Net4.DocAppender.CustomXMLDocPath static property.

Default assemblies are already added with this option turned on.

Kind regards,
Dmitry

Ok So I tested this, and it only works on Types not objects. How can I get it to see the object descriptions in Intellisense, or am I doing something wrong?

Hi Derek,

Could you please provide a sample of the TypeScript code that you’re trying to get IntelliSense information displayed?

Kind regards,
Dmitry

Here is a link to a sample project. It defines an object model. The top level object is of type Model.
I add an object of this type called Model and it does not provide the full intellisense, it only gives the names etc not the descriptions I entered for the model object:

Hi Derek,

Thank you for providing this project. We’ve fixed description generation for object types passed to the HostItemConfiguration- please refer to the attached screenshot.
We will push the fix to the NuGet packages shorty.

You will also need to include XML Documentation file option in the compiler options for AlternetTest project, so it will generate AlternetTest.xml with the descriptions that the Typescript generator uses to generate .d.ts files.

Regards,
Dmitry

Hi Derek,

We have just released an update (version 8.1.12) via NuGet, where this issue has been resolved.

You will need to turn on the XML documentation file in the Project Build option to generate .XML file with descriptions that TypeScript generator uses to generate .d.ts files with appropriate descriptions.

Please also ensure you add host object/host type with GenerateDescriptions option turned on:

    static void AddScriptingObject(Alternet.Syntax.Parsers.TypeScript.JavaScriptParser parser, string name, object value)
    {
        if (value is Type type)
        {
            parser.Repository.Project.HostItemsConfiguration.AddType(name, type, Alternet.Common.TypeScript.HostObjects.HostItemOptions.GenerateDescriptions);
        }
        else
        {
            parser.Repository.Project.HostItemsConfiguration.AddObject(name, value, Alternet.Common.TypeScript.HostObjects.HostItemOptions.GenerateDescriptions);
        }
    }

Kind regards,
Dmitry

Hi Dmitry,

I have included the latest nuget version in my test project and I dont get it working! Is the nuget updated properly or am I doing something wrong?

Here is my test project: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

Thanks

Hi Derek,

On my tests, It does display most descriptions - I’ve just run your demo project without any modifications.

It only does not get a description for AllObjects (as there’s still a problem with gathering descriptions for the generic methods, which we hope to fix in the coming major update).

Kind regards,
Dmitry

Hi Dmitry,

I copied this exact set of executables to windows sandbaox and it failes!!!
You must have some other dll’s on your test machine that is making it work.

If you take my project zip as is and copy to sandbox and run, it fails.

I hope this gives you enough data!!

Regards

Derek

I gave it a try just for fun, and for me it does not work either - no descriptions on the properties. Nuget package references seem to be correct.

When enabling “break on any exceptions” and uncheck “Enable Just my code”, then a lot of those internal exceptions happen:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
  HResult=0x80131500
  Message=Microsoft.ClearScript.ScriptObject enthält keine Definition für alternetTsParser.
  Source=Microsoft.CSharp
  StackTrace:
   at Microsoft.CSharp.RuntimeBinder.RuntimeBinderController.SubmitError(CError pError)

(translated to “ScriptObject does not contain a definition for alternetTsParser”, callstack contains “Alternet.Common.TypeScript.Compiler.V8Parser.RecreateParser”).

But this is probably not related.

Best regards

Wolfgang

Thanks Wolfgang, I almost thought I may be going nuts!!!

Hi Derek and Wolfgang,

We will try to reproduce this issue on the fresh machine.

Just wondering if you could look at the generated ts files on your tests (provided that you turned on XML Documentation file option in the .NET project)

Once you run the project, It should be located at
%Temp%Alternet.Scripter.TsTypedefsCache<sort of guid >\0\AutoGenerated\AlternetTest.d.ts

There might be lots of folders in the TsTypedefsCache folder, it’s safe to delete them all.

On my end this file looks like this, you can see document comments inside - this is where TypeScript parser gets documentation from.
…

 /**
 * 
        Top level class in the object model
        
 */
class Model extends System.Object {

	/**
	 * 
        Annotations in model
        
	 */
	Annotations: AlternetTest.Scripting.Annotations;

	/**
	 * 
        IEnumerable of all columns with formulae
        
	 */
	readonly CalculatedColumns: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.Column>;

…

Kind regards,
Dmitry

Hi Dmitry,

I re-ran in the sandbox and here is the corresponding snippet from the AlternetTest.d.ts file:

class Indexer_TableCollection {
	get(index: number): AlternetTest.Scripting.Table;
	get(name: string): AlternetTest.Scripting.Table;
}
class Indexer_TableItem {
	get(name: string): AlternetTest.Scripting.Table;
}
class Model extends System.Object {
	Annotations: AlternetTest.Scripting.Annotations;
	readonly CalculatedColumns: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.Column>;
	readonly CalculationList: System.Collections.Generic.IList<AlternetTest.Scripting.IDependencyItem>;
	readonly clrSuper: System.Object;
	readonly Columns: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.Column>;
	CreatedBy: string;
	CreatedDate: Date;
	readonly FileFolder: string;
	FileName: string;
	readonly Formulae: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.Formula>;
	readonly FullParentName: string;
	Name: string;
	readonly Objects: AlternetTest.Scripting.ObjectCollection;
	ScriptCode: string;
	readonly Tables: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.Table>;
	readonly Version: string;
	AllObjects(list: System.Collections.Generic.IEnumerable<AlternetTest.Scripting.QubeXLObject>): System.Collections.Generic.IEnumerable<AlternetTest.Scripting.QubeXLObject>;
	Calculate(): void;
	Clear(): void;
	ClearLog(): void;
	constructor();
	Equals(obj: any): boolean;

So it is not pulling through the comments.

I hope this helps

Regards

Derek

Hi Derek,

We have tried to reproduce this issue on the fresh machine, and it only fails if AlternetTest .xml is missing.

I’ve uploaded an updated demo project here, could you please try it again to see if it works for you?

Regards,
Andrew

Hi Dmitry,

Thanks, yes it works now. I tried to do the same in my main solution but dont get it working.

What is the rule on what XML file the .ts generator looks for?

I tried to add another scripting object called Lib. It creates another error that is illustrated in this slightly changed version of the project so you can get it tracked down.

Thanks

Derek

Hi Derek,

Thank you for reporting this problem, we’ve fixed it internally, and the fix will be included in the coming major update.

As for XML documentation file, it needs to be next to the assembly itself.
(or in case of .NET Framework libraries - we look at the framework folders as well).

You can also set Alternet.TsTypedefsGenerator.Core.Net4.DocAppender.CustomXMLDocPath - this way you can put all your document XML files in one folder.

Kind regards,
Dmitry

1 Like

Hi Derek,

We have just released a new version (v9). This issue should be addressed there.

Kind regards,
Dmitry