Open rodion-m opened 4 months ago
Here is scip file: https://drive.google.com/file/d/1rlhiFOg4ZWqMdc7kUxifC3PDDtivGXVG/view?usp=drive_link And json file for a comfort investigation: https://drive.google.com/file/d/11v-tjE9Ax6e0W2g0BBuxdrsQx6Zs0Wqq/view?usp=drive_link
Hello, can you clarify what you mean by
And then gave the file that contains only "scip-dotnet nuget . . ..." symbols
?
I ran the indexer on the project you mentioned (thanks for an open source reproducer), and I can see symbols such as this extracted with references and the rest of the information:
scip-dotnet nuget . . API/CatalogApi#GetImageMimeTypeFromImageFileExtension().
scip-dotnet nuget . . API/CatalogApi#GetImageMimeTypeFromImageFileExtension().(extension)
scip-dotnet nuget . . API/CatalogApi#GetFullPath().
scip-dotnet nuget . . API/CatalogApi#GetFullPath().(contentRootPath)
scip-dotnet nuget . . API/CatalogApi#GetFullPath().(pictureFileName)
The full grammar for reading symbol names is available in the SCIP repository, and the parts you refer to are, specifically:
// <symbol> ::= <scheme> ' ' <package> ' ' (<descriptor>)+ | 'local ' <local-id>
// <package> ::= <manager> ' ' <package-name> ' ' <version>
// <scheme> ::= any UTF-8, escape spaces with double space.
.
is used as a placeholder for empty value, where the indexer wasn't able to extract some information. For example in
scip-dotnet nuget . . API/CatalogApi#GetFullPath().(pictureFileName)
scheme = scip-dotnet package.manager = nuget package.package-name = . package.version = .
The rest of the symbol refers to the symbol name.
Not all indexers fill all the package fields, it depends on the completeness of the implementation and the particular project being indexed
Oh, thanks a lot for a fast reaction! But where are methods references? I thought that I'll be able to reproduce the full call graph from scip file, based on references that it provides.
Let's consider a method Order.AddOrderItem
from eShop.Ordering.Domain.AggregatesModel.OrderAggregate
.
This is what scip-dotnet gives:
{
"Symbol": "scip-dotnet nuget . . OrderAggregate/Order#AddOrderItem().",
"Documentation": [
"\u0060\u0060\u0060cs\npublic void Order.AddOrderItem(int productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, [int units = 1])\n\u0060\u0060\u0060"
],
"Relationships": []
},
So, Relationships
is empty. But Rider says that this method has 3 references:
Perhaps I'm doing something wrong. If yes, I'll appreciate your help on getting known how to retrieve all references (for AddOrderItem
method for example).
Also, I was wondering, is it possible to enable full namespace and full file path for a symbol?
Thank you for reporting! I was able to index the eshop repo and the index seems to be missing many references to global symbols. Steps to reproduce
# clone dotnet/eshop
cd eshop
scip-dotnet index
scip snapshot
open scip-snapshotsrc/HybridApp/MauiProgram.cs
In the screenshot below, you can see the missing references
When indexing, I did get an error about a missing maui-tizen workload
❯ scip-dotnet index eShop.sln
12:57:12 info: ScipDotnet.IndexCommandOptions[0] $ dotnet restore /Users/olafurpg/dev/dotnet/eshop/eShop.sln /p:EnableWindowsTargeting=true
Determining projects to restore...
/usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-tizen [/Users/olafurpg/dev/dotnet/eshop/tests/ClientApp.UnitTests/ClientApp.UnitTests.csproj]
/usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/Users/olafurpg/dev/dotnet/eshop/tests/ClientApp.UnitTests/ClientApp.UnitTests.csproj]
12:57:21 info: ScipDotnet.IndexCommandOptions[0] done: /Users/olafurpg/dev/dotnet/eshop/index.scip 9.6s
@rodion-m any idea how to fix that error?
@rodion-m The relationships
field is not used to show references. To find references, you need to iterate through all the occurrences of all the documents in the index to find ones with matching symbol
symbol_to_find = "scip-dotnet nuget . . OrderAggregate/Order#AddOrderItem()."
for document in index.documents:
for occurrence in document.occurrences:
if occurrence.symbol == symbol_to_find:
pass # TODO
Thank you for the answer! What about restoring a symbol full namespace?
I suppose that the error is about MAUI that should be installed. Here is an installation guide: https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?tabs=vswin&view=net-maui-8.0
What about restoring a symbol full namespace?
Can you elaborate what this means? A symbol has several parts:
scip-dotnet nuget . . OrderAggregate/Order#AddOrderItem().
^^^^^^^^^^^ indexer
^^^^^ package manager
^ package name ("." is anonymous)
^ package version ("." is anonymous)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ symbol descriptor
If you are referring to the package name/version, scip-dotnet does try to extract it but it may not be working 100% in all cases. We have a test case for this here
The best way to fix issues in this space is to reproduce then with a test case by writing code in the the "input" project like here https://github.com/sourcegraph/scip-dotnet/blob/main/snapshots/input/syntax/Main/Packages.cs
I've built scip-dotnet from sources, run it on eShop:
It worked for 20 seconds:
And then gave the file that contains only
"scip-dotnet nuget . . ..."
symbols. Like this:What am I doing wrong? I'd like to get all references (usages) for classes and their methods.