Skip to content
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

Upgrade F# language version for 8.0 #3392

Merged
merged 3 commits into from
Dec 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Microsoft.DotNet.Interactive.Jupyter.Protocol
public System.String Text { get;}
public System.String Type { get;}
public class CSharpLanguageInfo : LanguageInfo
.ctor(System.String version = 11.0)
.ctor(System.String version = 12.0)
public class DisplayData : PubSubMessage
.ctor(System.String source = null, System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object> data = null, System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object> metaData = null, System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object> transient = null)
public System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object> Data { get;}
Expand Down Expand Up @@ -285,7 +285,7 @@ Microsoft.DotNet.Interactive.Jupyter.Protocol
public System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object> Transient { get;}
public static class ExecutionStateValues
public class FSharpLanguageInfo : LanguageInfo
.ctor(System.String version = 7.0)
.ctor(System.String version = 8.0)
public abstract class HistoryElement
public System.Int32 LineNumber { get;}
public System.Int32 Session { get;}
Expand Down
36 changes: 18 additions & 18 deletions src/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type FSharpKernel () as this =
inherit Kernel("fsharp")

do this.KernelInfo.LanguageName <- "F#"
do this.KernelInfo.LanguageVersion <- "7.0"
do this.KernelInfo.LanguageVersion <- "8.0"
do this.KernelInfo.DisplayName <- $"{this.KernelInfo.LocalName} - F# Script"

static let lockObj = Object();
Expand Down Expand Up @@ -94,7 +94,7 @@ type FSharpKernel () as this =
match xmlDocuments.TryGetValue(xmlFile) with
| true, doc -> Some doc
| _ ->
if not (File.Exists(xmlFile)) ||
if not (File.Exists(xmlFile)) ||
not (String.Equals(Path.GetExtension(xmlFile), ".xml", StringComparison.OrdinalIgnoreCase)) then
None
else
Expand Down Expand Up @@ -223,7 +223,7 @@ type FSharpKernel () as this =
if not (tokenSource.IsCancellationRequested) then
let aggregateError = String.Join("\n", fsiDiagnostics)
match result with
| Error (:? FsiCompilationException)
| Error (:? FsiCompilationException)
| Ok _ ->
let ex = CodeSubmissionCompilationErrorException(Exception(aggregateError))
context.Fail(codeSubmission, ex, aggregateError)
Expand Down Expand Up @@ -263,7 +263,7 @@ type FSharpKernel () as this =
async {
match res.TryGetSymbolUse (mkPos line col) lineContent with
| Some symbolUse ->
let fullName =
let fullName =
match symbolUse with
| FsAutoComplete.Patterns.SymbolUse.Val sym ->
match sym.DeclaringEntity with
Expand Down Expand Up @@ -295,14 +295,14 @@ type FSharpKernel () as this =
|> Seq.concat
|> Seq.map (fun (signature, comment, footer) ->
// make footer look like in Ionide
let newFooter =
let newFooter =
footer.Split([|'\n'|], StringSplitOptions.RemoveEmptyEntries)
|> Seq.map (fun line -> line.TrimEnd('\r'))
|> Seq.filter (fsiAssemblyRx.IsMatch >> not)
|> Seq.map (sprintf "*%s*")
|> String.concat "\n\n----\n"

let markdown =
let markdown =
String.concat "\n\n----\n" [
if not (String.IsNullOrWhiteSpace signature) then
let code =
Expand All @@ -329,7 +329,7 @@ type FSharpKernel () as this =
]
| Some None ->
sprintf "%s // null" signature
| _ ->
| _ ->
signature

sprintf "```fsharp\n%s\n```" code
Expand Down Expand Up @@ -358,7 +358,7 @@ type FSharpKernel () as this =
context.Publish(HoverTextProduced(requestHoverText, reply, lps))
()
}

let handleRequestDiagnostics (requestDiagnostics: RequestDiagnostics) (context: KernelInvocationContext) =
task {
let _parseResults, checkFileResults, _checkProjectResults = script.Value.Fsi.ParseAndCheckInteraction(requestDiagnostics.Code)
Expand Down Expand Up @@ -393,7 +393,7 @@ type FSharpKernel () as this =
|> List.filter (fun x -> x.Name <> "it") // don't report special variable `it`
|> List.map (fun x -> KernelValue( new KernelValueInfo(x.Name, new FormattedValue(PlainTextFormatter.MimeType, x.Value.ToDisplayString(PlainTextFormatter.MimeType)) , x.Value.ReflectionType), x.Value.ReflectionValue, this.Name))

member this.getValueType(name:string) =
member this.getValueType(name:string) =
match script.Value.Fsi.TryFindBoundValue(name) with
| Some cv ->
cv.Value.ReflectionValue.GetType()
Expand All @@ -408,7 +408,7 @@ type FSharpKernel () as this =
| _ ->
false

member this.AddAssemblyReferencesAndPackageRoots(assemblyReferences: IEnumerable<string>, packageRoots: IEnumerable<string>) =
member this.AddAssemblyReferencesAndPackageRoots(assemblyReferences: IEnumerable<string>, packageRoots: IEnumerable<string>) =
let sb = StringBuilder()
let hashset = HashSet()

Expand All @@ -420,7 +420,7 @@ type FSharpKernel () as this =
if File.Exists root then
sb.AppendFormat("#I @\"{0}\"", root) |> ignore
sb.Append(Environment.NewLine) |> ignore

for assemblyReference in assemblyReferences do
if hashset.Add(assemblyReference) then
if File.Exists assemblyReference then
Expand All @@ -434,23 +434,23 @@ type FSharpKernel () as this =
member this.HandleAsync(command: RequestCompletions, context: KernelInvocationContext) = handleRequestCompletions command context

interface IKernelCommandHandler<RequestDiagnostics> with
member this.HandleAsync(command: RequestDiagnostics, context: KernelInvocationContext) = handleRequestDiagnostics command context
member this.HandleAsync(command: RequestDiagnostics, context: KernelInvocationContext) = handleRequestDiagnostics command context

interface IKernelCommandHandler<RequestHoverText> with
member this.HandleAsync(command: RequestHoverText, context: KernelInvocationContext) = handleRequestHoverText command context
member this.HandleAsync(command: RequestHoverText, context: KernelInvocationContext) = handleRequestHoverText command context

interface IKernelCommandHandler<RequestValueInfos> with
member this.HandleAsync(command: RequestValueInfos, context: KernelInvocationContext) = handleRequestValueValueInfos command context
member this.HandleAsync(command: RequestValueInfos, context: KernelInvocationContext) = handleRequestValueValueInfos command context

interface IKernelCommandHandler<RequestValue> with
member this.HandleAsync(command: RequestValue, context: KernelInvocationContext) = handleRequestValue command context
member this.HandleAsync(command: RequestValue, context: KernelInvocationContext) = handleRequestValue command context

interface IKernelCommandHandler<SendValue> with
member this.HandleAsync(command: SendValue, context: KernelInvocationContext) =
let handle (name : string) (value : obj) (declaredType : Type) : Task =
member this.HandleAsync(command: SendValue, context: KernelInvocationContext) =
let handle (name : string) (value : obj) (declaredType : Type) : Task =
script.Value.Fsi.AddBoundValue(name, value)
Task.CompletedTask
base.SetValueAsync(command, context, handle)
base.SetValueAsync(command, context, handle)

interface IKernelCommandHandler<SubmitCode> with
member this.HandleAsync(command: SubmitCode, context: KernelInvocationContext) = handleSubmitCode command context
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public LanguageInfo(string name, string version, string mimeType, string fileExt

public class CSharpLanguageInfo : LanguageInfo
{
public CSharpLanguageInfo(string version = "11.0") : base("C#", version, "text/x-csharp", ".cs", pygmentsLexer: "csharp")
public CSharpLanguageInfo(string version = "12.0") : base("C#", version, "text/x-csharp", ".cs", pygmentsLexer: "csharp")
{
}
}

public class FSharpLanguageInfo : LanguageInfo
{
public FSharpLanguageInfo(string version = "7.0") : base("F#", version, "text/x-fsharp", ".fs", pygmentsLexer: "fsharp")
public FSharpLanguageInfo(string version = "8.0") : base("F#", version, "text/x-fsharp", ".fs", pygmentsLexer: "fsharp")
{
}
}
Expand Down