-
Notifications
You must be signed in to change notification settings - Fork 1k
[Core] Avoid showing duplicated files in project tree #9309
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| using System.Linq; | ||
| using System.Runtime.CompilerServices; | ||
| using Mono.Addins; | ||
| using MonoDevelop.Core; | ||
| using MonoDevelop.Projects; | ||
|
|
||
| namespace MonoDevelop.Ide.Projects.FileNesting | ||
|
|
@@ -166,7 +167,7 @@ public ProjectFileNestingInfo (ProjectFile projectFile) | |
| } | ||
| } | ||
|
|
||
| readonly ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> (); | ||
| readonly ConcurrentDictionary<FilePath, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<FilePath, ProjectFileNestingInfo> (); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a comment that the FilePath is used as a workaround, we should be using ProjectFile. |
||
| bool fileNestingEnabled; | ||
|
|
||
| public Project Project { get; } | ||
|
|
@@ -195,10 +196,10 @@ void EnsureInitialized () | |
|
|
||
| ProjectFileNestingInfo AddFile (ProjectFile projectFile) | ||
| { | ||
| var tmp = projectFiles.GetOrAdd (projectFile, new ProjectFileNestingInfo (projectFile)); | ||
| var tmp = projectFiles.GetOrAdd (projectFile.FilePath, new ProjectFileNestingInfo (projectFile)); | ||
| tmp.Parent = FileNestingService.InternalGetParentFile (projectFile); | ||
| if (tmp.Parent != null) { | ||
| var parent = projectFiles.GetOrAdd (tmp.Parent, new ProjectFileNestingInfo (tmp.Parent)); | ||
| var parent = projectFiles.GetOrAdd (tmp.Parent.FilePath, new ProjectFileNestingInfo (tmp.Parent)); | ||
| if (parent.Children == null) { | ||
| parent.Children = new ProjectFileCollection (); | ||
| } | ||
|
|
@@ -207,19 +208,19 @@ ProjectFileNestingInfo AddFile (ProjectFile projectFile) | |
| } | ||
| } | ||
|
|
||
| projectFiles [projectFile] = tmp; | ||
| projectFiles [projectFile.FilePath] = tmp; | ||
| return tmp; | ||
| } | ||
|
|
||
| ProjectFileNestingInfo RemoveFile (ProjectFile projectFile, List<ProjectFile> originalFilesToRemove = null) | ||
| { | ||
| bool actuallyRemoveFiles = originalFilesToRemove == null; | ||
|
|
||
| projectFiles.TryRemove (projectFile, out var nestingInfo); | ||
| projectFiles.TryRemove (projectFile.FilePath, out var nestingInfo); | ||
|
|
||
| // Update parent | ||
| if (nestingInfo?.Parent != null) { | ||
| if (projectFiles.TryGetValue (nestingInfo.Parent, out var tmp)) { | ||
| if (projectFiles.TryGetValue (nestingInfo.Parent.FilePath, out var tmp)) { | ||
| tmp.Children.Remove (projectFile); | ||
| } | ||
| } | ||
|
|
@@ -296,7 +297,7 @@ public ProjectFile GetParentForFile (ProjectFile inputFile) | |
| if (!fileNestingEnabled) | ||
| return null; | ||
|
|
||
| return projectFiles.TryGetValue (inputFile, out var nestingInfo) ? nestingInfo.Parent : null; | ||
| return projectFiles.TryGetValue (inputFile.FilePath, out var nestingInfo) ? nestingInfo.Parent : null; | ||
| } | ||
|
|
||
| public ProjectFileCollection GetChildrenForFile (ProjectFile inputFile) | ||
|
|
@@ -305,7 +306,7 @@ public ProjectFileCollection GetChildrenForFile (ProjectFile inputFile) | |
| if (!fileNestingEnabled) | ||
| return null; | ||
|
|
||
| return projectFiles.TryGetValue (inputFile, out var nestingInfo) ? nestingInfo.Children : null; | ||
| return projectFiles.TryGetValue (inputFile.FilePath, out var nestingInfo) ? nestingInfo.Children : null; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rodrmoya Can you remember why you had to change the FileNestingService here for the duplicate files? Just wondering if the other pull request is enough to fix the problem since that change would only affect the files in the Solution pad window, not the files belonging to the project.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, so
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not see any duplicate files in the Solution pad. Just wondering what would happen here with the nesting if Project.Files contained duplicate files, but with different conditions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or well, maybe it's not needed at all, as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be affected indeed, as files are stored on a dictionary -> https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.FileNesting/FileNestingService.cs#L198 with the I'll have a look and see how/if it gets affected |
||
|
|
||
| public void Dispose () | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need a comment on the fact that this hashset is needed as a workaround.