dotnet / dotnet/project-system
Project context representation in cloud environments
- Dominant language
- C#
- Stars
- 1k
- Forks
- 415
- PR merge metrics
- No merged PRs in 30d
Description
We need a representation of a project context for an open document, which encapsulates the notion of configuration, TFM, RID, and possibly other properties.
**Project System protocol APIs**
We distinguish a _project_ from a _project instance_. The former entity represents a `.proj` file and corresponds to nodes in Solution Explorer. A _project_ is parameterized by configuration, platform, TFM, etc. A _project instance_ is a specific instantiation of a project with given values for these parameters.
Each _project_ and _project instance_ is assigned a GUID that's guaranteed to be unique within the lifetime of the object model that represents these entities in the project system service. The GUIDs are assigned (generated) when solution is opened and populated with projects and cease to have a meaning when the solution is closed. The GUIDs are not persisted on disk.
```C#
struct ProjectContext
{
Guid ProjectInstanceId;
string Configuration;
string Platform;
string DisplayName;
}
ProjectContext[] GetProjectContexts(Uri documentUri);
```
Project System passes `ProjectContext` to Roslyn along with each project instance it creates.
`GetProjectContexts` finds all project instances that contain given file (follows linked files, shared projects, etc. to their referencing projects).
**Client (VS/VS Code)**
Client calls `GetProjectContexts` to retrieve a list of contexts available for a given source file. It constructs the context list in navbar based on this information (grouped by `Configuration` and `Platform`).
LSP includes `ProjectInstanceId` in the request context for each document related request.
**User session service**
Remembers current contexts of open documents.
**Roslyn**
Roslyn uses `ProjectInstanceId` to identify projects in its object model (`ProjectId`).
Roslyn LSP server implementation uses `ProjectInstanceId` from the request context to map the request to the `Project` instance in its object model.
Contributor guide
Assessment
This issue has not been assessed yet.