Skip to content

Commit 6c2b27d

Browse files
committed
Treat System.Private.CoreLib as a system lib for extension method search
1 parent 6cdcc3c commit 6c2b27d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Compiler/AbstractIL/ilread.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ and typeDefReader ctxtH : ILTypeDefStored =
21482148
ctxt.fileName.EndsWith("System.Runtime.dll")
21492149
|| ctxt.fileName.EndsWith("mscorlib.dll")
21502150
|| ctxt.fileName.EndsWith("netstandard.dll")
2151+
|| ctxt.fileName.EndsWith("System.Private.CoreLib.dll")
21512152

21522153
while attrIdx <= attrsEndIdx && not containsExtensionMethods do
21532154
let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx

tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,22 @@ tInput.Length
352352
let value = opt.Value
353353
Assert.Equal(4L, downcast value.ReflectionValue)
354354

355+
[<Fact>]
356+
member _.``ML - use assembly with ref dependencies and without refing SMemory``() =
357+
let code = """
358+
#r "nuget:Microsoft.ML.OnnxTransformer,1.4.0"
359+
360+
open System
361+
open System.Numerics.Tensors
362+
let inputValues = [| 12.0; 10.0; 17.0; 5.0 |]
363+
let tInput = new DenseTensor<float>(inputValues.AsMemory(), new ReadOnlySpan<int>([|4|]))
364+
tInput.Length
365+
"""
366+
use script = new FSharpScript(additionalArgs=[| "/usesdkrefs-" |])
367+
let opt = script.Eval(code) |> getValue
368+
let value = opt.Value
369+
Assert.Equal(4L, downcast value.ReflectionValue)
370+
355371
[<Fact>]
356372
member _.``System.Device.Gpio - Ensure we reference the runtime version of the assembly``() =
357373
let code = """

0 commit comments

Comments
 (0)