Skip to content

Commit

Permalink
Backport to dev17.11 - Bugfix extension method in dotnet interactive (#…
Browse files Browse the repository at this point in the history
…17801)

* Treat System.Private.CoreLib as a system lib for extension method search

* usessdkrefs is not a valid option for desktop compiler
  • Loading branch information
T-Gro authored Sep 27, 2024
1 parent be2636f commit e9ac555
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,7 @@ and typeDefReader ctxtH : ILTypeDefStored =
ctxt.fileName.EndsWith("System.Runtime.dll")
|| ctxt.fileName.EndsWith("mscorlib.dll")
|| ctxt.fileName.EndsWith("netstandard.dll")
|| ctxt.fileName.EndsWith("System.Private.CoreLib.dll")

while attrIdx <= attrsEndIdx && not containsExtensionMethods do
let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ tInput.Length
let value = opt.Value
Assert.Equal(4L, downcast value.ReflectionValue)

[<FSharp.Test.FactForNETCOREAPP>] // usessdkrefs is not a valid option for desktop compiler
member _.``ML - use assembly with ref dependencies and without refing SMemory``() =
let code = """
#r "nuget:Microsoft.ML.OnnxTransformer,1.4.0"
open System
open System.Numerics.Tensors
let inputValues = [| 12.0; 10.0; 17.0; 5.0 |]
let tInput = new DenseTensor<float>(inputValues.AsMemory(), new ReadOnlySpan<int>([|4|]))
tInput.Length
"""
use script = new FSharpScript(additionalArgs=[| "/usesdkrefs-" |])
let opt = script.Eval(code) |> getValue
let value = opt.Value
Assert.Equal(4L, downcast value.ReflectionValue)

[<Fact>]
member _.``System.Device.Gpio - Ensure we reference the runtime version of the assembly``() =
let code = """
Expand Down

0 comments on commit e9ac555

Please sign in to comment.