Skip to content

Commit

Permalink
Merge pull request dotnet#28623 from amcasey/FilePath
Browse files Browse the repository at this point in the history
Use FilePath in VisualStudioWorkspaceImpl.AddDocumentToProjectItems
  • Loading branch information
amcasey authored Jul 26, 2018
2 parents 63433fb + 9d95105 commit a9c960d
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,15 @@ private void AddDocumentCore(DocumentInfo info, SourceText initialText, bool isA

if (IsWebsite(project))
{
AddDocumentToFolder(hostProject, project, info.Id, SpecializedCollections.SingletonEnumerable(AppCodeFolderName), info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToFolder(hostProject, project, info.Id, SpecializedCollections.SingletonEnumerable(AppCodeFolderName), info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}
else if (folders.Any())
{
AddDocumentToFolder(hostProject, project, info.Id, folders, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToFolder(hostProject, project, info.Id, folders, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}
else
{
AddDocumentToProject(hostProject, project, info.Id, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToProject(hostProject, project, info.Id, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}

var undoManager = TryGetUndoManager();
Expand Down Expand Up @@ -644,7 +644,8 @@ private ProjectItem AddDocumentToProject(
string filePath = null,
bool isAdditionalDocument = false)
{
if (!project.TryGetFullPath(out var folderPath))
string folderPath = null;
if (filePath == null && !project.TryGetFullPath(out folderPath))
{
// TODO(cyrusn): Throw an appropriate exception here.
throw new Exception(ServicesVSResources.Could_not_find_location_of_folder_on_disk);
Expand All @@ -665,7 +666,9 @@ private ProjectItem AddDocumentToFolder(
bool isAdditionalDocument = false)
{
var folder = project.FindOrCreateFolder(folders);
if (!folder.TryGetFullPath(out var folderPath))

string folderPath = null;
if (filePath == null && !folder.TryGetFullPath(out folderPath))
{
// TODO(cyrusn): Throw an appropriate exception here.
throw new Exception(ServicesVSResources.Could_not_find_location_of_folder_on_disk);
Expand Down

0 comments on commit a9c960d

Please sign in to comment.