这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@KevinRansom
Copy link
Contributor

No description provided.

events
.Should()
.ContainSingle(e => e is NuGetPackageAdded);
.ContainSingle(e => e is DisplayedValueUpdated && ((DisplayedValueUpdated)e).Value.ToString().Contains("done!"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a much weaker assertion than checking for the specific event type.

Copy link
Contributor Author

@KevinRansom KevinRansom Dec 4, 2019

Choose a reason for hiding this comment

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

Immediately below is this assertion, which accurately verifies the event:
The line above verifies that the updated output text is produced.

            events.OfType<PackageAdded>()
                  .Should()
                  .BeEquivalentTo(new NugetPackageReference("Microsoft.Extensions.Logging", "2.2.0"));
                  .ContainSingle(e => ((PackageAdded)e).PackageReference.PackageName == "Microsoft.Extensions.Logging" 
                                   && ((PackageAdded)e).PackageReference.PackageVersion == "2.2.0");


namespace Microsoft.DotNet.Interactive.Commands
{
public class NugetRestoreDirective : KernelCommandBase
Copy link
Contributor

Choose a reason for hiding this comment

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

Command naming is typically imperative, e.g. RestoreNugetPackage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

K.

IKernel kernel,
KernelInvocationContext context,
IEnumerable<FileInfo> additionalDependencies = null)
IEnumerable<string> additionalDependencies = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think additionalDependencies should be able to be removed in favor of something easier to understand. Not sure if you've seen an opportunity to do that but don't be worried about breaking existing extension functionality because it needs to be redone anyway.

var packageKey = requestedPackage.PackageKey;

if (!string.IsNullOrEmpty(packageName) && _nugetPackageReferences.TryGetValue(requestedPackage, out _))
lock (_packageReferences)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than needing a lock, you can use ConcurrentDictionary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

probingPaths))
.ToDictionary(r => r.PackageName, StringComparer.OrdinalIgnoreCase);

lock (_lockObject)
Copy link
Contributor

Choose a reason for hiding this comment

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

lock (_lockObject) [](start = 11, length = 19)

This lock looks unnecessary.

{
public PackageRestoreResult(
bool succeeded,
IEnumerable<PackageReference> requestedPackages,
Copy link
Contributor

Choose a reason for hiding this comment

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

IEnumerable requestedPackages, [](start = 12, length = 48)

This is unused.

}

[Fact]
public async Task PoundRNugetDisallowsEmptyPackageSpecification()
Copy link
Contributor

Choose a reason for hiding this comment

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

PoundRNugetDisallowsEmptyPackageSpecification [](start = 26, length = 45)

Test naming quibble: snake case please.


namespace Microsoft.DotNet.Interactive.Commands
{
public class RestoreNugetDirective : KernelCommandBase
Copy link
Contributor

Choose a reason for hiding this comment

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

RestoreNugetDirective [](start = 17, length = 21)

Would RestorePackages capture the intent here? You've removed "Nuget" from other class names, and "Directive" sounds like the direct object here, which isn't accurate.

@KevinRansom
Copy link
Contributor Author

@jonsequitur
It tells me I can't merge the PR. Nor can I resolve the conflicts.

I will resolve them On my PC and push another commit.

image

throw new System.ArgumentNullException(nameof(addPackage));
}

PackageReference = addPackage.PackageReference;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's preferable to take in the PackageReference directly here. Then long as the parameter name matches the property name (case-insensitive), the deserialization will work correctly.

.Last()
.Value
.Should()
.Be("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change? This doesn't look like the correct behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it isn't ...

@KevinRansom
Copy link
Contributor Author

@jonsequitur
GitHub hates me:

image

@jonsequitur jonsequitur merged commit d0fbb15 into dotnet:master Dec 12, 2019
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.

2 participants