From b8b7d98256f54482523f929c23fc590624288a00 Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Tue, 22 Nov 2016 14:41:56 -0800 Subject: [PATCH] last touches --- .../MsbuildProjectExtensions.cs | 2 +- src/dotnet/commands/dotnet-add-p2p/Program.cs | 5 ++--- src/dotnet/commands/dotnet-add/Program.cs | 10 ++++----- src/dotnet/dotnet.csproj | 9 +++++++- test/dotnet-add-p2p.Tests/Extensions.cs | 5 ++--- .../dotnet-add-p2p.Tests/GivenDotnetAddP2P.cs | 21 ++++++++++--------- test/dotnet-add-p2p.Tests/ProjDir.cs | 7 ------- test/dotnet-add-p2p.Tests/TestSetup.cs | 8 +++---- 8 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/dotnet/commands/dotnet-add-p2p/MsbuildProjectExtensions.cs b/src/dotnet/commands/dotnet-add-p2p/MsbuildProjectExtensions.cs index 1e3bd9488..6385bd40a 100644 --- a/src/dotnet/commands/dotnet-add-p2p/MsbuildProjectExtensions.cs +++ b/src/dotnet/commands/dotnet-add-p2p/MsbuildProjectExtensions.cs @@ -46,7 +46,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference public static ProjectItemGroupElement FindExistingUniformItemGroupWithCondition(this ProjectRootElement root, string projectItemElementType, string framework) { - return root.ItemGroupsReversed.FirstOrDefault((ig) => ig.IsConditionalOnFramework(framework) && ig.IsUniformItemElementType(projectItemElementType)); + return root.ItemGroupsReversed.FirstOrDefault((itemGroup) => itemGroup.IsConditionalOnFramework(framework) && itemGroup.IsUniformItemElementType(projectItemElementType)); } public static bool IsUniformItemElementType(this ProjectItemGroupElement group, string projectItemElementType) diff --git a/src/dotnet/commands/dotnet-add-p2p/Program.cs b/src/dotnet/commands/dotnet-add-p2p/Program.cs index ebd8d7d0d..fa1fb36f2 100644 --- a/src/dotnet/commands/dotnet-add-p2p/Program.cs +++ b/src/dotnet/commands/dotnet-add-p2p/Program.cs @@ -215,7 +215,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference int numberOfAddedReferences = 0; const string ProjectItemElementType = "ProjectReference"; - ProjectItemGroupElement ig = null; + ProjectItemGroupElement itemGroup = root.FindUniformOrCreateItemGroupWithCondition(ProjectItemElementType, framework); foreach (var @ref in refs.Select((r) => NormalizeSlashesForMsbuild(r))) { if (root.HasExistingItemWithCondition(framework, @ref)) @@ -225,8 +225,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference } numberOfAddedReferences++; - ig = ig ?? root.FindUniformOrCreateItemGroupWithCondition(ProjectItemElementType, framework); - ig.AppendChild(root.CreateItemElement(ProjectItemElementType, @ref)); + itemGroup.AppendChild(root.CreateItemElement(ProjectItemElementType, @ref)); Reporter.Output.WriteLine($"Reference `{@ref}` added to the project."); } diff --git a/src/dotnet/commands/dotnet-add/Program.cs b/src/dotnet/commands/dotnet-add/Program.cs index 1e3b2b29a..2418fdb6e 100644 --- a/src/dotnet/commands/dotnet-add/Program.cs +++ b/src/dotnet/commands/dotnet-add/Program.cs @@ -18,17 +18,17 @@ namespace Microsoft.DotNet.Tools.Add { public const string HelpText = @".NET Add Command -Usage: dotnet add [options] [object] [[--] ...]] +Usage: dotnet add [options] [[--] ...]] + +Options: + -h|--help Show help information Arguments: The object of the operation. If a project file is not specified, it defaults to the current directory. Command to be executed on . -Options: - -h|--help Show help information - Args: - Any extra arguments passed to the command. + Any extra arguments passed to the command. Use `dotnet add --help` to get help about these arguments. Commands: p2p Add project to project (p2p) reference to a project"; diff --git a/src/dotnet/dotnet.csproj b/src/dotnet/dotnet.csproj index c5af004c3..3de77d4ca 100755 --- a/src/dotnet/dotnet.csproj +++ b/src/dotnet/dotnet.csproj @@ -1,5 +1,6 @@  + 1.0.0-preview4 netcoreapp1.0 @@ -10,11 +11,13 @@ true $(PackageTargetFallback);dotnet5.4 + + @@ -22,6 +25,7 @@ + 1.0.0-alpha-20161104-2 @@ -74,11 +78,14 @@ 1.0.1-beta-000933 + $(DefineConstants);NETCOREAPP1_0 + $(DefineConstants);RELEASE + - \ No newline at end of file + diff --git a/test/dotnet-add-p2p.Tests/Extensions.cs b/test/dotnet-add-p2p.Tests/Extensions.cs index 31070e853..218e1dbcc 100644 --- a/test/dotnet-add-p2p.Tests/Extensions.cs +++ b/test/dotnet-add-p2p.Tests/Extensions.cs @@ -2,9 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Build.Construction; -using System; -using System.Linq; using Microsoft.DotNet.ProjectJsonMigration; +using System.Linq; using System.Collections.Generic; namespace Microsoft.DotNet.Cli.Add.P2P.Tests @@ -13,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Add.P2P.Tests { public static int NumberOfItemGroupsWithConditionContaining(this ProjectRootElement root, string patternInCondition) { - return root.ItemGroups.Count((ig) => ig.Condition.Contains(patternInCondition)); + return root.ItemGroups.Count((itemGroup) => itemGroup.Condition.Contains(patternInCondition)); } public static int NumberOfItemGroupsWithoutCondition(this ProjectRootElement root) diff --git a/test/dotnet-add-p2p.Tests/GivenDotnetAddP2P.cs b/test/dotnet-add-p2p.Tests/GivenDotnetAddP2P.cs index e9cb2dc2c..1d602f78c 100644 --- a/test/dotnet-add-p2p.Tests/GivenDotnetAddP2P.cs +++ b/test/dotnet-add-p2p.Tests/GivenDotnetAddP2P.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.IO; -using Microsoft.DotNet.Tools.Test.Utilities; -using Xunit; using FluentAssertions; using Microsoft.Build.Construction; +using Microsoft.DotNet.Tools.Test.Utilities; +using System; +using System.IO; +using Xunit; namespace Microsoft.DotNet.Cli.Add.P2P.Tests { @@ -20,19 +20,21 @@ namespace Microsoft.DotNet.Cli.Add.P2P.Tests private TestSetup Setup([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(Setup), string identifier = "") { return new TestSetup( - GetTestGroupTestAssetsManager(TestSetup.TestGroup) - .CreateTestInstance(TestSetup.ProjectName, callingMethod: callingMethod, identifier: identifier) - .Path); + TestAssets.Get(TestSetup.TestGroup, TestSetup.ProjectName) + .CreateInstance() + .WithSourceFiles() + .Root + .FullName); } private ProjDir NewDir([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(NewDir), string identifier = "") { - return new ProjDir(TestAssetsManager, callingMethod, identifier: identifier); + return new ProjDir(TestAssetsManager.CreateTestDirectory(callingMethod: callingMethod, identifier: identifier).Path); } private ProjDir NewLib([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(NewDir), string identifier = "") { - var dir = new ProjDir(TestAssetsManager, callingMethod, identifier: identifier); + var dir = NewDir(callingMethod: callingMethod, identifier: identifier); try { @@ -76,7 +78,6 @@ namespace Microsoft.DotNet.Cli.Add.P2P.Tests } [Fact] - public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage() { string projName = "Broken/Broken.csproj"; diff --git a/test/dotnet-add-p2p.Tests/ProjDir.cs b/test/dotnet-add-p2p.Tests/ProjDir.cs index 2b568ae78..2f449d630 100644 --- a/test/dotnet-add-p2p.Tests/ProjDir.cs +++ b/test/dotnet-add-p2p.Tests/ProjDir.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.IO; -using Microsoft.DotNet.TestFramework; using Microsoft.Build.Construction; using Microsoft.Build.Evaluation; @@ -10,12 +9,6 @@ namespace Microsoft.DotNet.Cli.Add.P2P.Tests { internal class ProjDir { - public ProjDir(TestAssetsManager tam, [System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(ProjDir), string identifier = "") - { - Path = tam.CreateTestDirectory(callingMethod: callingMethod, identifier: identifier).Path; - Name = new DirectoryInfo(Path).Name; - } - public ProjDir(string path) { Path = path; diff --git a/test/dotnet-add-p2p.Tests/TestSetup.cs b/test/dotnet-add-p2p.Tests/TestSetup.cs index be7dda378..7fe1e3cf8 100644 --- a/test/dotnet-add-p2p.Tests/TestSetup.cs +++ b/test/dotnet-add-p2p.Tests/TestSetup.cs @@ -1,9 +1,7 @@ -using Microsoft.DotNet.TestFramework; -using Microsoft.DotNet.Tools.Test.Utilities; -using System; -using System.Collections.Generic; +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System.IO; -using System.Text; namespace Microsoft.DotNet.Cli.Add.P2P.Tests {