Merge pull request #7636 from wli3/fix-parser-warning

Do not move forward if there is parsing error
This commit is contained in:
Daniel Plaisted 2017-09-12 17:38:07 -07:00 committed by GitHub
commit b925a30be2
3 changed files with 52 additions and 3 deletions

View file

@ -53,8 +53,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4
build\Publish.targets = build\Publish.targets
build\RestoreDependency.proj = build\RestoreDependency.proj
build\sdks\sdks.csproj = build\sdks\sdks.csproj
build\Signing.proj = build\Signing.proj
build\SetupPreviousStage.props = build\SetupPreviousStage.props
build\Signing.proj = build\Signing.proj
build\Test.targets = build\Test.targets
build\Version.props = build\Version.props
build\VersionBadge.props = build\VersionBadge.props
@ -229,6 +229,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdk
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-cli-build.Tests", "build_projects\dotnet-cli-build.Tests\dotnet-cli-build.Tests.csproj", "{84BB2DD5-B2D8-4C85-AAF9-29D2A74FBF94}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-restore.Tests", "test\dotnet-restore.Tests\dotnet-restore.Tests.csproj", "{B4EE3671-C103-4A37-8DEB-C74E0134104E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1589,6 +1591,30 @@ Global
{84BB2DD5-B2D8-4C85-AAF9-29D2A74FBF94}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{84BB2DD5-B2D8-4C85-AAF9-29D2A74FBF94}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{84BB2DD5-B2D8-4C85-AAF9-29D2A74FBF94}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|x64.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|x64.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|x86.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Debug|x86.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.MinSizeRel|x86.Build.0 = Debug|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|Any CPU.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|x64.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|x64.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|x86.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.Release|x86.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{B4EE3671-C103-4A37-8DEB-C74E0134104E}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1660,6 +1686,7 @@ Global
{602976C5-2477-4B4C-AD9A-1EAFB250529A} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{FCDFAF40-CC16-4D49-96C0-E49F195E7142} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{84BB2DD5-B2D8-4C85-AAF9-29D2A74FBF94} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{B4EE3671-C103-4A37-8DEB-C74E0134104E} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B526D2CE-EE2D-4AD4-93EF-1867D90FF1F5}

View file

@ -167,7 +167,12 @@ namespace Microsoft.DotNet.Cli
int exitCode;
if (BuiltInCommandsCatalog.Commands.TryGetValue(command, out var builtIn))
{
TelemetryEventEntry.SendFiltered(Parser.Instance.ParseFrom($"dotnet {command}", appArgs.ToArray()));
var parseResult = Parser.Instance.ParseFrom($"dotnet {command}", appArgs.ToArray());
if (!parseResult.Errors.Any())
{
TelemetryEventEntry.SendFiltered(parseResult);
}
exitCode = builtIn.Command(appArgs.ToArray());
}
else

View file

@ -7,6 +7,7 @@ using Microsoft.DotNet.Cli.Telemetry;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Test.Utilities;
using System.Collections.Generic;
using System;
using Xunit;
namespace Microsoft.DotNet.Tests
@ -24,6 +25,22 @@ namespace Microsoft.DotNet.Tests
TelemetryEventEntry.TelemetryFilter = new TelemetryFilter();
}
[Fact]
public void NoTelemetryIfCommandIsInvalid()
{
string[] args = { "publish", "-r"};
Action a = () => { Cli.Program.ProcessArgs(args); };
a.ShouldNotThrow<ArgumentOutOfRangeException>();
}
[Fact]
public void NoTelemetryIfCommandIsInvalid2()
{
string[] args = { "restore", "-v" };
Action a = () => { Cli.Program.ProcessArgs(args); };
a.ShouldNotThrow<ArgumentOutOfRangeException>();
}
[Fact]
public void TopLevelCommandNameShouldBeSentToTelemetry()
{
@ -120,7 +137,7 @@ namespace Microsoft.DotNet.Tests
public void DotnetNugetCommandFirstArgumentShouldBeSentToTelemetry()
{
const string argumentToSend = "push";
string[] args = {"nuget", argumentToSend, "aRoot"};
string[] args = {"nuget", argumentToSend};
Cli.Program.ProcessArgs(args);
_fakeTelemetry
.LogEntries.Should()