Skip to content

Commit

Permalink
Upgrade F# language version for 8.0 (#3392)
Browse files Browse the repository at this point in the history
* update F# lang version to 8.0

* also upgrade LanguageInfo for CSharp

* fix baseline file for Assent tests

---------

Co-authored-by: Jon Sequeira <jonsequeira@gmail.com>
  • Loading branch information
kojo12228 and jonsequitur committed Dec 22, 2023
1 parent d0c47d0 commit bc12bb7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
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

0 comments on commit bc12bb7

Please sign in to comment.