Skip to content
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
2 changes: 1 addition & 1 deletion docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Fixed

* Fix extension methods support for non-reference system assemblies ([PR #17799](https://github.com/dotnet/fsharp/pull/17799))
* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))

### Added
Expand Down
14 changes: 3 additions & 11 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,11 +2144,6 @@ and typeDefReader ctxtH : ILTypeDefStored =
else
let mutable attrIdx = attrsStartIdx

let looksLikeSystemAssembly =
ctxt.fileName.EndsWith("System.Runtime.dll")
|| ctxt.fileName.EndsWith("mscorlib.dll")
|| ctxt.fileName.EndsWith("netstandard.dll")

while attrIdx <= attrsEndIdx && not containsExtensionMethods do
let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx
// skip parentIndex to read typeIndex
Expand All @@ -2159,12 +2154,9 @@ and typeDefReader ctxtH : ILTypeDefStored =
let name =
if attrTypeIndex.tag = cat_MethodDef then
// the ExtensionAttribute constructor can be cat_MethodDef if the metadata is read from the assembly
// in which the corresponding attribute is defined -- from the system library
if not looksLikeSystemAssembly then
""
else
let _, (_, nameIdx, namespaceIdx, _, _, _) = seekMethodDefParent ctxt attrCtorIdx
readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx)
// in which the corresponding attribute is defined
let _, (_, nameIdx, namespaceIdx, _, _, _) = seekMethodDefParent ctxt attrCtorIdx
readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx)
else
let mutable addr = ctxt.rowAddr TableNames.MemberRef attrCtorIdx
let mrpTag = seekReadMemberRefParentIdx ctxt mdv &addr
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
Loading