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

Add support for transitive NoWarn properties from project references #1672

Merged
merged 39 commits into from
Aug 29, 2017

Conversation

mishra14
Copy link
Contributor

Porting over from : #1642

This branch contains a slightly different implementation with minimal warning property storage at each node in the graph.

Spec: https://github.com/NuGet/Home/wiki/%5BSpec%5D-Transitive-Warning-Properties
Fixes: NuGet/Home#5691 and NuGet/Home#5501

This change adds the capability to flow NoWarn properties transitively. The details are in the spec along with a high level implementation detail section.

@mishra14 mishra14 changed the title [Min Data]: Add support for transitive NoWarn properties from project references [Min]: Add support for transitive NoWarn properties from project references Aug 26, 2017

var targetFrameworkInformation = packageSpec
.TargetFrameworks
.First(tfi => tfi.FrameworkName == framework);
Copy link
Member

Choose a reason for hiding this comment

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

Use packageSpec.GetTargetFramework, it should have this optimization already, and it will ensure that if a comparer is needed that we already have it

{
get
{
if (_transitiveWarningPropertiesCollection == null)
Copy link
Member

Choose a reason for hiding this comment

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

🥇

/// Compares two sets for equality, allowing either sequence to be null.
/// If one is null, both have to be null for equality.
/// </summary>
internal static bool SetEqualWithNullCheck<T>(
Copy link
Member

Choose a reason for hiding this comment

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

Make equals plural to match the other methods

// Add a constant hash for all objects
hashCode.AddObject(1);

return hashCode.CombinedHash;
Copy link
Member

Choose a reason for hiding this comment

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

Why not just return 1 if this isn't changing?

private bool IsWarningSuppressed(IRestoreLogMessage message)
{

if (ProjectWarningPropertiesCollection != null && ProjectWarningPropertiesCollection.ApplyWarningProperties(message))
Copy link
Member

Choose a reason for hiding this comment

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

nit: ProjectWarningPropertiesCollection?.ApplyWarningProperties(message) == true would simplify these

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using NuGet.DependencyResolver;
Copy link
Member

Choose a reason for hiding this comment

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

sort

@emgarten
Copy link
Member

NuGet.Commands.Test.StandaloneProjectTests.StandaloneProject_BasicRestore fails due to not having a project path set. Adding it to the test fixes it, you might also want to consider handling this gracefully.

@mishra14 mishra14 changed the title [Min]: Add support for transitive NoWarn properties from project references Add support for transitive NoWarn properties from project references Aug 28, 2017
Copy link
Member

@emgarten emgarten left a comment

Choose a reason for hiding this comment

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

🏇 🥇

@@ -130,6 +130,8 @@ public void Log(IRestoreLogMessage message)
// This will be true if the message is not or warning or it is not suppressed.
if (!IsWarningSuppressed(message))
{
UpgradeWarningIfNeeded(message);
Copy link
Member

Choose a reason for hiding this comment

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

add a comment explaining what this does

@mishra14 mishra14 merged commit 4be29f3 into dev Aug 29, 2017
@mishra14 mishra14 deleted the dev-anmishr-p2pnowarnfast branch August 29, 2017 23:41
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.

3 participants