-
Notifications
You must be signed in to change notification settings - Fork 563
Load extensions using #r nuget directive #396
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
Changes from all commits
420f1a5
4882760
d95faaf
7830ed8
5e324b8
250ca23
1146d66
28186e3
5c94058
77b3eee
1a46dca
4fac550
0d3882f
6cdffe6
e398066
93f65e4
c102080
48382d3
bfdbc1f
6348524
d848153
78cfa3d
6652f25
37b137a
39f8dc4
759fd84
afc4505
ec7b101
626f6ba
0c4c9ee
4759b66
4bed9c7
a94e294
a0c25a2
7264096
4812f7f
c9eed93
7c9cca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using Xunit; | ||
| using MLS.Agent.Tools; | ||
| using Microsoft.DotNet.Interactive; | ||
| using FluentAssertions; | ||
| using System.Linq; | ||
| using MLS.Agent.Tools.Tests; | ||
| using System.IO; | ||
| using System.Runtime.InteropServices.ComTypes; | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.Tests | ||
| { | ||
| public class NuGetPackagePathResolverTests | ||
| { | ||
| [Fact] | ||
| public void Can_find_path_of_nuget_package() | ||
| { | ||
| var firstPackageRef = new NugetPackageReference("first", "2.0.0"); | ||
| var secondPackageRef = new NugetPackageReference("second", "3.0.0"); | ||
| var directory = new InMemoryDirectoryAccessor() | ||
| { | ||
| ($"{firstPackageRef.PackageName}/{firstPackageRef.PackageVersion}/lib/netstandard2.0/{firstPackageRef.PackageName}.dll", ""), | ||
| ($"{secondPackageRef.PackageName}/{secondPackageRef.PackageVersion}/lib/netstandard2.0/{secondPackageRef.PackageName}.dll", "") | ||
| }; | ||
|
|
||
| NuGetPackagePathResolver.TryGetNuGetPackageBasePath(firstPackageRef, directory.GetAllFilesRecursively().Select(file => directory.GetFullyQualifiedFilePath(file)), out var nugetPackageDirectory); | ||
|
|
||
| nugetPackageDirectory.GetFullyQualifiedRoot().FullName.Should().Be(directory.GetFullyQualifiedPath(new RelativeDirectoryPath($"{firstPackageRef.PackageName}/{firstPackageRef.PackageVersion}")).FullName); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // 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.Collections; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.Commands | ||
| { | ||
| public class LoadExtensionFromNuGetPackage : KernelCommandBase | ||
| { | ||
| public LoadExtensionFromNuGetPackage(NugetPackageReference nugetPackageReference, IEnumerable<FileInfo> metadataReferences) | ||
| { | ||
| NugetPackageReference = nugetPackageReference ?? throw new ArgumentNullException(nameof(nugetPackageReference)); | ||
| MetadataReferences = metadataReferences ?? throw new ArgumentNullException(nameof(metadataReferences)); | ||
| } | ||
|
|
||
| public NugetPackageReference NugetPackageReference { get; } | ||
| public IEnumerable<FileInfo> MetadataReferences { get; } | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // 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 Microsoft.DotNet.Interactive.Commands; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.Events | ||
| { | ||
| public class KernelExtensionLoadException : KernelEventBase | ||
| { | ||
| public KernelExtensionLoadException(string message) | ||
| { | ||
| Message = message ?? throw new System.ArgumentNullException(nameof(message)); | ||
| } | ||
|
|
||
| public string Message { get; } | ||
|
|
||
| public override string ToString() => $"{base.ToString()}: {Message}"; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // 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 Microsoft.DotNet.Interactive.Commands; | ||
| using Microsoft.DotNet.Interactive.Events; | ||
| using System.IO; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive | ||
| { | ||
| public class ExtensionLoaded : KernelEventBase | ||
| { | ||
| public ExtensionLoaded(FileInfo extensionPath) | ||
akshita31 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| ExtensionPath = extensionPath ?? throw new System.ArgumentNullException(nameof(extensionPath)); | ||
| } | ||
|
|
||
| public FileInfo ExtensionPath { get; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // 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 MLS.Agent.Tools; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive | ||
| { | ||
| public interface IExtensibleKernel | ||
| { | ||
| public Task LoadExtensionsInDirectory(IDirectoryAccessor directory, KernelInvocationContext invocationContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will there always be an invocation context? What about extensions that we want to load on startup?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to "Publish" an event saying that the extension has been loaded and we need the context for that. If we would like to load extensions at startup, how would we "Publish" that event if we dont have the KernelInvocationContext ? I think once we have that scenario, it would not be a hard change to make this method maybe return a list of extensions that it loaded(so that it can be called at startup) and then the caller can do whatever necessary. Thoughts ? |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.