Updating X#Model.xsdb Database outside of Visual Studio

This forum is meant for anything you would like to share with other visitors
Post Reply
VR
Posts: 98
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

Updating X#Model.xsdb Database outside of Visual Studio

Post by VR »

Hello,

as announced by Robert some time ago, there is a "hidden" SQLite db containing information about the source code (like which file contains which class). As I understand it, this file is updated by Visual Studio.

Is there a way to update this database also without opening it in Visual Studio by calling some command line tool? I think of for example building the project with ms build and adding a parameter.

I'm thinking of generating some documentation based on the git commits. But since git stores files and a file could contain multiple classes or a class could be contained in multiple files, the X#Model.xsdb Database would be very useful to connect the file names to the x# classes.

Kind regards

​​​​​​​Volkmar
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Updating X#Model.xsdb Database outside of Visual Studio

Post by robert »

Volkmar,
The database is a normal SQLite database.
The code that we use to update this database is inside "XSharpModel.dll"
The source code is written in X#: https://github.com/X-Sharp/XSharpPublic ... tabase.prg
That repo has the project file as well so you can see its dependencies.
We are sending in XProject, XAssembly and XFile objects.
We are returning a List of XDbResult objects when reading objects from the database or simply a list of strings.
I think the code is fairly straight forward.
For quick queries I use SQLite manager in FireFox or the Database.Net too from https://fishcodelib.com/Database.htm

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
VR
Posts: 98
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

Updating X#Model.xsdb Database outside of Visual Studio

Post by VR »

The querying of the database is not the problem. The missing piece of the puzzle is a simple way to make sure, that the database is up to date. Maybe some day in the future you can provide a command line tool, that I can call to update the database of a solution. Then the process would be:
* Get the latest commits from git
* Execute the Command Line tool to update the database
* Execute a tool that executes some queries on the database and export some data

I checked the XSharpCodeModelXs dependencies and currently the EnvDTE.dll is included. Not sure, if I can create a wapper to a DLL, that uses the EnvDTE.dll.

Kind regards

Volkmar
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Updating X#Model.xsdb Database outside of Visual Studio

Post by robert »

Volkmar,

EnvDTE is used to keep track of references from X# projects to non x# projects (C#, VB etc).
We use this to locate the output files for these projects.
We could probably remove this and use reflection to retrieve the properties for these projects.

I'll see if I can create a command line tool to update the database.
I have considered to use a separate "service" inside VS as well (that is what Roslyn does) but then everything (also type lookups etc) has to be handled by this service, since we are working with an in memory database.
It has the advantage that the memory for the type info is not part of VS and that background parsing will happen in a separate process.
The disadvantage is that "direct" calls have to be replaced by process to process communication (for example using named pipes).

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
VR
Posts: 98
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

Updating X#Model.xsdb Database outside of Visual Studio

Post by VR »

Today I found another use case, where the hidden SQlite database is useful... I can update it with Visual Studio for now, but it still would be great to have a way without Visual Studio.
Would it be possible to add a custom build switch to the MSBuild command to update the db? I don't know, but I think, that the compiler should already have many of the data that is necessary for the update.
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Updating X#Model.xsdb Database outside of Visual Studio

Post by robert »

Volkmar,

The compiler does NOT update the database. This is done by the assembly XSharpModel.dll.
And this assembly is not loaded in the build process.
So the answer is: this is not easy.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply