Repository navigation
Generate error message for duplicate items - #624
Conversation
c68c901 to
687a64f
Compare
687a64f to
08f2893
Compare
| <value>Duplicate {0} items were included.{1} The duplicate items were: {2}</value> | ||
| </data> | ||
| <data name="DuplicateItemsHowToFix" xml:space="preserve"> | ||
| <value> You can either remove these items from your project file, or set the '{0}' property to '{1}' if you want to explicitly include them in your project file.{2}</value> |
There was a problem hiding this comment.
I suspect that the experiences of #623 and dotnet/project-system#1126 indicate that we should also promote the Update and Remove mechanisms here. But that makes a very long error, which isn't ideal.
| MoreInformationLink="$(DefaultItemsMoreInformationLink)" | ||
| /> | ||
|
|
||
| <!-- TODO: Do we check for duplicate content items here, or in the Web SDK? EnableDefaultContentItems isn't defined or used at all by the .NET SDK --> |
There was a problem hiding this comment.
I'd say to do it here because Content is a type known in Common.targets, and this is the closest layer above that. If it were defined and used only in Web, I'd say to move it there.
| } | ||
|
|
||
| // TODO: Does quoting and the separator between items in the list need to be localized? | ||
| string duplicateItemsFormatted = string.Join(", ", duplicateItems.Select(d => $"'{d.Key}'")); |
There was a problem hiding this comment.
I don't know what the right answer is. My guess is: change this to a semicolon (like MSBuild uses to separate items) and don't localize it (MSBuild itself doesn't seem to, probably in part because there's no distinction between "format list of items to print" and "format list of items to pass a string to code" which would have different localization needs).
| <value>Duplicate {0} items were included.{1} The duplicate items were: {2}</value> | ||
| </data> | ||
| <data name="DuplicateItemsHowToFix" xml:space="preserve"> | ||
| <value> You can either remove these items from your project file, or set the '{0}' property to '{1}' if you want to explicitly include them in your project file.{2}</value> |
There was a problem hiding this comment.
This is really hard to follow for translators: leading whitespace, placeholder followed by two spaces followed by another sentence, placeholder immediately after a sentence. Can we just log consecutive independent messages? If not, maybe don't worry about DRY and just put the full text of each message a user can see so the translator has all of the context. At a minimum, use the <comment> element to explain how these compose.
|
|
||
| protected override void ExecuteCore() | ||
| { | ||
| var duplicateItems = Items.GroupBy(i => i.ItemSpec).Where(g => g.Count() > 1).ToList(); |
There was a problem hiding this comment.
Also is g.Count() cheap here in practice? (do the groups implement ICollection?)
I would be interested in seeing some measurment where this task shows up on the perf summary. Maybe it doesn't register in comparison to surrounding logic, but my instinct from lower level work is to cringe at all of this LINQ.
I think the question is, are we checking for duplicate items in general, or are we just checking for duplicate items caused by the implicit includes in the SDK? Does adding an extra check and error message add value if the problem is unrelated to the implicit includes? I'm leaning towards saying that these checks and error messages should only apply when implicit includes are enabled. That would also mean that the validation for @rainersigwald @nguerrera @srivatsn Thoughts? |
… generate error if implicit items are enabled
|
I've updated the PR to only use one resource string for the error message. It should now look like this (mostly the same as it was previously):
I've also modified it to only generate the error if the implicit items were enabled. If not, then it will be up to targets further down the pipeline to detect the issue and generate an error as they always have. |
|
@MattGertz for approval ScenarioA user upgrades from RC2 to RC3. The projects they created with RC2 will generate compile errors saying that the source files were specified multiple times. This is because we now include the source files implicitly. This change will generate an error message that explains how to fix the issue:
BugWorkaroundsn/a RiskLow - Tests should cover any impacted scenarios Performance ImpactTBD but should be low - it involves calling an additional task for each of the Regression Analysisn/a |
|
|
||
| <PropertyGroup> | ||
| <!-- TODO: Create a fwlink for this --> | ||
| <DefaultItemsMoreInformationLink>https://github.com/dotnet/sdk</DefaultItemsMoreInformationLink> |
There was a problem hiding this comment.
We need to have an acceptable link before we merge.
| { | ||
| if (DefaultItemsEnabled && DefaultItemsOfThisTypeEnabled) | ||
| { | ||
| var duplicateItems = Items.GroupBy(i => i.ItemSpec).Where(g => g.Count() > 1).ToList(); |
There was a problem hiding this comment.
Can required inputs be null? Change to
(Items ?? Enumerable<ITaskItem>.Empty())|
Shiproom approved |
|
@dsplaisted where does the new link go to? |
|
@BlackDwarf It goes to https://github.com/dotnet/core/blob/master/release-notes/sdk-implicit-items.md. You're an owner of the link as well @terrajobst, @richlander, and a few others. |
|
When I upgraded my project from VS2017 RC to VS2017 it causes an error in all my class library projects. After reinstalling VS (yes I read that it was the solution ...) I deleted the line |
|
I think this explains it: https://github.com/dotnet/core/blob/master/release-notes/1.0/sdk/1.0-rc3-default-compile-items.md. Does that make sense? |
…0190424.4 (dotnet#624) - Microsoft.AspNetCore.Mvc.Analyzers - 3.0.0-preview6-19224-04 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 3.0.0-preview6-19224-04
Fixes #600
Generate an error message if there are duplicate
Compile,EmbeddedResource, orContentitems. The error message looks like this:If default items are disabled, then the error message won't include information about how to disable them:
Open questions or other notes:
Contentitems, or since it doesn't have any logic for them by default should that go in the Web SDK?Noneitems, as I don't think those would typically cause an issue