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

Set working folder for the solution added. #31448

Merged
merged 2 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Microsoft.VisualStudio.LanguageServices.Storage;
using Microsoft.VisualStudio.Shell.Interop;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Expand Down Expand Up @@ -84,6 +85,10 @@ public VisualStudioProject CreateAndAddToWorkspace(string projectUniqueName, str
VersionStamp.Create(),
solutionPathToSetWithOnSolutionAdded,
projects: new[] { projectInfo }));

// set working folder for the persistent service
var persistenceService = w.Services.GetRequiredService<IPersistentStorageLocationService>() as VisualStudioPersistentStorageLocationService;
persistenceService?.UpdateForVisualStudioWorkspace(w);
}
else
{
Expand Down
Expand Up @@ -150,5 +150,14 @@ static void Main()
}
});
}

[WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)]
public void VerifyWorkingFolder()
{
SetUpEditor(@"class EmptyContent {$$}");

// verify working folder has set
Assert.NotNull(VisualStudio.Workspace.GetWorkingFolder());
}
}
}
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.LanguageServices;
Expand Down Expand Up @@ -171,5 +172,11 @@ public void SetFeatureOption(string feature, string optionName, string language,

optionService.SetOptions(optionService.GetOptions().WithChangedOption(optionKey, value));
});

public string GetWorkingFolder()
{
var service = _visualStudioWorkspace.Services.GetRequiredService<IPersistentStorageLocationService>();
return service.TryGetStorageLocation(_visualStudioWorkspace.CurrentSolution.Id);
}
}
}
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Shared.TestHooks;
Expand Down Expand Up @@ -78,5 +79,7 @@ public void SetFullSolutionAnalysis(bool value)

public void SetFeatureOption(string feature, string optionName, string language, string valueString)
=> _inProc.SetFeatureOption(feature, optionName, language, valueString);

public string GetWorkingFolder() => _inProc.GetWorkingFolder();
}
}