Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fix 4521: Add dotnet-add-p2p #4758

Merged
merged 18 commits into from
Nov 28, 2016
Merged

Fix 4521: Add dotnet-add-p2p #4758

merged 18 commits into from
Nov 28, 2016

Conversation

krwq
Copy link
Member

@krwq krwq commented Nov 17, 2016

Copy link

@TheRealPiotrP TheRealPiotrP left a comment

Choose a reason for hiding this comment

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

Great start! I see it's a WiP so much of the commentary is likely already planned to be addressed. Key points:

  • I think we can simplify the predicates approach
  • I don't see why we have another parser. We're not saving much [5%, maybe] on LoC and yet we're paying for YAP(tm) [Yet another parser].
  • Need more test coverage

</PropertyGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -24,6 +24,7 @@
using Microsoft.DotNet.Tools.Test;
using Microsoft.DotNet.Tools.VSTest;
using NuGet.Frameworks;
using Microsoft.DotNet.Tools.Add;

This comment was marked as spam.

This comment was marked as spam.

@@ -45,6 +46,7 @@ public class Program
["run"] = RunCommand.Run,
["test"] = TestCommand.Run,
["vstest"] = VSTestCommand.Run,
["add"] = AddCommand.Run,

This comment was marked as spam.

This comment was marked as spam.

FullName = ".NET Add Project to Project (p2p) reference Command",
Description = "Command to add project to project (p2p) reference"
};
app.HelpOption("-h|--help");

This comment was marked as spam.

This comment was marked as spam.

app.HelpOption("-h|--help");

CommandArgument projectArgument = app.Argument("<PROJECT>",
"The MSBuild project file to modify. If a project file is not specified," +

This comment was marked as spam.

This comment was marked as spam.

new AddP2PCommand()
.WithWorkingDirectory(testRoot)
.Execute($"{Lib2Path} -r {Lib4Path} -f net451")
.Should().Pass();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

new AddP2PCommand()
.WithWorkingDirectory(testRoot)
.Execute($"{Lib2Path} -r {Lib4Path} -f netcoreapp1.0")
.Should().Pass();

This comment was marked as spam.

string lib2FullPath = Path.Combine(testRoot, Lib2Path);
CountOccurrances(File.ReadAllText(lib2FullPath), "Lib4.csproj").Should().Be(2);

new RestoreCommand()

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

return ret;
}
}
}

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

#endif
}
}
}

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@TheRealPiotrP
Copy link

Any updates on this one?

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<PackageReference Include="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<PackageReference Include="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,8 @@
using System;

namespace SomeNS

This comment was marked as spam.

This comment was marked as spam.

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<PackageReference Include="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<PackageReference Include="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<PackageReference Include="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<!-- This is intentionally empty - do not remove -->
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">

This comment was marked as spam.

This comment was marked as spam.

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

@@ -27,14 +27,18 @@ public static bool IsEquivalentTo(this ProjectItemElement item, ProjectItemEleme
// Different includes
if (item.IntersectIncludes(otherItem).Count() != item.Includes().Count())
{
#if !DISABLE_TRACE

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

return false;
}

// Different Excludes
if (item.IntersectExcludes(otherItem).Count() != item.Excludes().Count())
{
#if !DISABLE_TRACE

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


if (files.Length > 1)
{
throw new GracefulException("Found more than one MSBuild project in the current directory. Please specify which one to use.");

This comment was marked as spam.

}

[Fact]

This comment was marked as spam.

This comment was marked as spam.

@krwq krwq changed the title [WIP/For preview] Fix 4521: Add dotnet-add-p2p Fix 4521: Add dotnet-add-p2p Nov 22, 2016
@livarcocc
Copy link

@dotnet-bot Test this please

@krwq krwq dismissed TheRealPiotrP’s stale review November 23, 2016 19:06

added a lot of changes, need to be reviewed again

@krwq
Copy link
Member Author

krwq commented Nov 23, 2016

Seems like I got some non-windows issues, I'll investigate this


namespace Microsoft.DotNet.Tools
{
internal static class Strings

This comment was marked as spam.

This comment was marked as spam.

{
internal static class Strings
{
// Arguments parsing

This comment was marked as spam.

This comment was marked as spam.

CommandOptionType.NoValue);

app.OnExecute(() => {
if (string.IsNullOrEmpty(projectArgument.Value))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

}

// There is ProjectRootElement.TryOpen but it does not work as expected
// I.e. it returns null for some valid projects

This comment was marked as spam.

This comment was marked as spam.

public AddP2PCommand()
: base("dotnet")
{

This comment was marked as spam.

This comment was marked as spam.


namespace Microsoft.DotNet.Cli.Add.P2P.Tests
{
internal static class Extensions

This comment was marked as spam.

This comment was marked as spam.

return root.ItemGroups.Count((ig) => string.IsNullOrEmpty(ig.Condition));
}

public static IEnumerable<ProjectElement> ItemsWithIncludeAndConditionContaining(this ProjectRootElement root, string itemType, string includePattern, string patternInCondition)

This comment was marked as spam.

This comment was marked as spam.

});
}

public static int NumberOfProjectReferencesWithIncludeAndConditionContaining(this ProjectRootElement root, string includePattern, string patternInCondition)

This comment was marked as spam.

This comment was marked as spam.

return root.ItemsWithIncludeAndConditionContaining("ProjectReference", includePattern, patternInCondition).Count();
}

public static IEnumerable<ProjectElement> ItemsWithIncludeContaining(this ProjectRootElement root, string itemType, string includePattern)

This comment was marked as spam.

This comment was marked as spam.

@TheRealPiotrP
Copy link

:shipit:

@TheRealPiotrP
Copy link

@srivatsn @MattGertz please approve

@MattGertz
Copy link

Your wish is my command... :-)

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.

9 participants