Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a WorkspaceKind property to ProjectContext. #75384

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,16 @@ public static LSP.VSProjectContext ProjectToProjectContext(Project project)
projectContext.Kind = LSP.VSProjectKind.VisualBasic;
}

var solution = project.Solution;
if (solution.WorkspaceKind == WorkspaceKind.Host)
{
projectContext.WorkspaceKind = LSP.VSWorkspaceKind.Host;
}
else if (solution.WorkspaceKind == WorkspaceKind.MiscellaneousFiles)
{
projectContext.WorkspaceKind = LSP.VSWorkspaceKind.MiscellaneousFiles;
}

return projectContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public VSProjectKind Kind
set;
}

/// <summary>
/// Gets or sets the kind of the workspace the project context is associated.
/// </summary>
[JsonPropertyName("_vs_workspace_kind")]
public VSWorkspaceKind WorkspaceKind
{
get;
set;
}

public static bool operator ==(VSProjectContext? value1, VSProjectContext? value2)
{
if (ReferenceEquals(value1, value2))
Expand Down
22 changes: 22 additions & 0 deletions src/LanguageServer/Protocol/Protocol/Extensions/VSWorkspaceKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Roslyn.LanguageServer.Protocol
{
/// <summary>
/// <see cref="VSWorkspaceKind" /> represents the various kinds of known workspaces.
/// </summary>
internal enum VSWorkspaceKind
{
/// <summary>
/// Host Workspace
/// </summary>
Host = 1,

/// <summary>
/// Miscellaneous Files Workspace
/// </summary>
MiscellaneousFiles = 2,
}
}
Loading