Page 1 of 1
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Jan 14, 2021 2:36 pm
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
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Jan 14, 2021 3:36 pm
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
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Jan 14, 2021 5:12 pm
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
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Jan 14, 2021 5:49 pm
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
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Apr 29, 2021 2:24 pm
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.
Updating X#Model.xsdb Database outside of Visual Studio
Posted: Thu Apr 29, 2021 3:23 pm
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