Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Conversation

@rodrmoya
Copy link
Contributor

@rodrmoya rodrmoya commented Nov 14, 2019

There are some cases where, it seems, we don't evaluate conditions as we should,
resulting in duplicated items being added to the project and, thus, also shown
in the project tree (see dotnet/aspnetcore#17088).

Also, by just adding a , duplicated files show also.

So, due to this limitation on the project system, work around it on the project
tree, by checking for duplicates based on the files' paths.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1005277

@rodrmoya
Copy link
Contributor Author

@monojenkins backport release-8.4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a big perf hit from object reference equality vs full string match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to have FilePath as the key, but not sure what to do with the perf, the work around works because we check the file paths, as the files are duplicated in project.Files, so can't do object reference equality.

There are some cases where, it seems, we don't evaluate conditions as we should,
resulting in duplicated items being added to the project and, thus, also shown
in the project tree (see dotnet/aspnetcore#17088).

Also, by just adding a <None Include="*"/>, duplicated files show also.

So, due to this limitation on the project system, work around it on the project
tree, by checking for duplicates based on the files' paths.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1005277
@rodrmoya rodrmoya force-pushed the pr-fix-dupe-evaluated-items branch from 05eb293 to 24ba1ff Compare November 14, 2019 19:54
@rodrmoya
Copy link
Contributor Author

@monojenkins backport release-8.4

{
string folderPrefix = folder + Path.DirectorySeparatorChar;

var visitedFiles = new HashSet<FilePath> ();
Copy link
Contributor

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.

}

readonly ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> ();
readonly ConcurrentDictionary<FilePath, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<FilePath, ProjectFileNestingInfo> ();
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@mrward
Copy link
Member

mrward commented Dec 2, 2019

Alternative fix here which should address the underlying problem of Conditions being ignored on the Content items - #9407

@rodrmoya
Copy link
Contributor Author

rodrmoya commented Dec 2, 2019

Closing this one then

@rodrmoya rodrmoya closed this Dec 2, 2019
@rodrmoya rodrmoya deleted the pr-fix-dupe-evaluated-items branch December 2, 2019 19:13

return projectFiles.TryGetValue (inputFile, out var nestingInfo) ? nestingInfo.Children : null;
return projectFiles.TryGetValue (inputFile.FilePath, out var nestingInfo) ? nestingInfo.Children : null;
}
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, so FileNestingService deals with the files in the project, not the solution pad really, so if the files in the project are still duplicated, I guess maybe we need this change after all?

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or well, maybe it's not needed at all, as FileNestingService is called from the node builders, so if those don't get the duplicated files, it should be ok. But not sure, as the service listens to FileAdded/Removed events on the project to keep the data up to date

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 ProjectFile being the key, so maybe it makes sense to get the FileNestingService's changes of this PR, although, as @Therzok mentioned, that adds a big perf hit :/

I'll have a look and see how/if it gets affected

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants