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

Fix spurious warnings in dependency node #2435

Merged
merged 1 commit into from
Jun 14, 2017
Merged

Conversation

natidea
Copy link
Contributor

@natidea natidea commented Jun 13, 2017

Customer scenario

Customers observe spurious and confusing warning icons in dependency node when there should not be any, or do not observe warning icons when there should be. This collection of small targeted fixes addresses the most common cases, including:

  • referencing a .NET Framework project always warns even though these P2P refs are valid, which is a regression from 15.2
  • valid P2P refs sometimes do not expand (particularly to cps-based .NET Framework projects) because of invalid IDs being passed around
  • (NuGet) diagnostics do not bubble up correctly

One side-effect: P2P references to incompatible projects should have a warning icon but does not (however, there are warning messages in the error list). Three separate bugs in NuGet, SDK and Project System are preventing this scenario from working properly, and will need to be addressed later or post 15.3. I've filed #2436 and NuGet/Home#5405 to track fixing this. This seems like a fair tradeoff since users are still warned and the build will fail if user tries to setup an incompatible dependency. Additionally, this side effect is not a regression since this did not work in 15.2 either.

Bugs this fixes:

Fixes #2242
Bug 431059

Workarounds, if any

None

Risk

Low, targeted fixes that only affect dependency node. Postponed more complicated fixes to SDK (#2436)

Performance impact

(with a brief justification for that assessment (e.g. "Low perf impact because no extra allocations/no complexity changes" vs. "Low")

Is this a regression from a previous update?

Yes. Dependency node was rewritten and we are working through some behavior changes.

Root cause analysis:

Incorrect IDs is a subtle bug occurring because a CPS method is calling UnconfiguredProject.MakeRooted (see UnattachedProjectItemTreeNode.cs:75 ). The warning on all .NET Framework projects is because the heuristic to determine if TargetFrameworks are compatible is unable to find information for these projects -- this fix changes the heuristic to only report warnings when it can find information.

How was the bug found?

Internal Dogfooders

/cc @dotnet/project-system

…mework projects and due to incorrect IDs for P2P dependencies
@srivatsn
Copy link
Contributor

Tagging @MattGertz for 15.3

return id.Replace('/', '\\');
return id
.Replace('/', '\\')
.Replace("..", "__");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there no API that can do this normalization for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a targeted fix to workaround the fact that CPS calls MakeRooted which alters the ID. Long term perhaps we should consider replacing the id with a more opaque hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

This could be problematic. This ID becomes the canonical name of the IVsHierarchy item, and there are places we expect to be able to extract the original file path from the canonical name (for example, analyzer support in Solution Explorer).

Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't be interpreting the moniker - that is only for the project system itself to reason about. You should be using hierarchy properties to retrieve any data you need.

Copy link
Member

Choose a reason for hiding this comment

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

So was this regressed given we merged this in?

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 have not seen a regression in Analyzers. I believe Analyzers use an absolute path so it would not be impacted by this.

Copy link
Member

@davkean davkean Jun 22, 2017

Choose a reason for hiding this comment

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

Okay, I thought about this more, I can see why analyzers did this originally, analyzers look like the following in the project file:

<ItemGroup>
    <Analyzer Include="Analyzer.dll" />
</ItemGroup>

This looks a lot like like source files:

<ItemGroup>
    <Compile Include="Foo.cs"/>
</ItemGroup>

I cansee why we return the analyzer's canonical name as the same as the path of the analyzer.

However, I will state - we should not be expecting or interpreting that outside of the project system. There are other APIs for retrieving a file path given a canonical/mkdocument name, we should be using that. We're theoretically allowed to return whatever we want for a canonical name, for example, that canonical name would be problematic in the following:

<ItemGroup>
    <Analyzer Include="Analyzer.dll" />
    <None Include="Analyzer.dll" /> 
</ItemGroup>

These are going to have the same canonical name even though they are supposed to be unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When referencing a desktop project from a netcoreapp project the project node appears with yellow triangle
7 participants