Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Microsoft.DotNet.Interactive.CSharp/CSharpKernelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Commands;
Expand Down Expand Up @@ -44,8 +45,20 @@ public static CSharpKernel UseKernelHelpers(

public static CSharpKernel UseNugetDirective(this CSharpKernel kernel)
{
var packageRefArg = new Argument<PackageReference>((SymbolResult result, out PackageReference reference) =>
PackageReference.TryParse(result.Token.Value, out reference))
var packageRefArg = new Argument<PackageReference>(
result =>
{
var token = result.Tokens.Select(t => t.Value).SingleOrDefault();
if (PackageReference.TryParse(token, out var reference))
{
return reference;
}
else
{
result.ErrorMessage = $"Could not parse \"{token}\" as a package reference.";
return null;
}
})
{
Name = "package"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
open System
open System.CommandLine
open System.CommandLine.Invocation
open System.CommandLine.Parsing
open System.Runtime.CompilerServices
open System.Threading.Tasks
open Microsoft.AspNetCore.Html
Expand Down Expand Up @@ -60,7 +61,7 @@ open System.Linq"
let command = Command(detailedName)
command.Handler <- CommandHandler.Create(
fun (parseResult: ParseResult) (context: KernelInvocationContext) ->
let detailed = parseResult.CommandResult.Token.Value = detailedName
let detailed = parseResult.CommandResult.Command.Name = detailedName
match context.Command with
| :? SubmitCode ->
match context.HandlingKernel with
Expand Down
9 changes: 4 additions & 5 deletions Microsoft.DotNet.Interactive.Formatting/Formatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,10 @@ public static string GetDefaultMimeType()
return _defaultMimeType;
}

public static string PreferredMimeTypeFor(Type type)
{
return _preferredMimeTypesByType.TryGetValue(type, out var mimeType) ? mimeType : null;
}

public static string PreferredMimeTypeFor(Type type) =>
_preferredMimeTypesByType.TryGetValue(type, out var mimeType)
? mimeType
: _defaultMimeType;

public static string ToDisplayString(
this object obj,
Expand Down
Loading