Skip to content

FSI netcore not seeing System.Security.Cryptography asm #14024

@kevmal

Description

@kevmal

In VS Version 17.4.0 Preview 2.1 editing a fsx file with "Use .NET Core Scripting" enabled:

image

Not showing any types from System.Security.Cryptography asm, (Aes, AesCcm, AesCng, ...)

In FSI (F# Interactive version 12.0.5.0 for F# 7.0):

$ dotnet fsi

Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> System.Security.Cryptography.MD5.Create();;

  System.Security.Cryptography.MD5.Create();;
  -----------------------------^^^

stdin(12,30): error FS0039: The value, constructor, namespace or type 'MD5' is not defined.

Yet reflection works fine:

 > type ComputeHash = delegate of byte[] -> byte[]
let computeHash  =
    let asm = System.AppDomain.CurrentDomain.GetAssemblies() |> Seq.find (fun x -> x.FullName.StartsWith("System.Security.Cryptography,"))
    let md5 = asm.GetTypes() |> Seq.find (fun x -> x.Name = "MD5")
    let computeHashMeth = md5.GetMethod("ComputeHash", [| typeof<byte[]> |])
    let md5obj = md5.GetMethod("Create",[||]).Invoke(null,[||])
    let d : ComputeHash = computeHashMeth.CreateDelegate(md5obj)
    fun x -> d.Invoke x
;;
type ComputeHash =
  delegate of byte[] -> byte[]
val computeHash: (byte[] -> byte[])

> computeHash [|0uy|];;
val it: byte[] =
  [|147uy; 184uy; 133uy; 173uy; 254uy; 13uy; 160uy; 137uy; 205uy; 246uy; 52uy;
    144uy; 79uy; 213uy; 159uy; 113uy|]

A F# net7.0 project works fine
image

Compiles and runs.

FSI without "Use .NET Core Scripting" works fine.

Metadata

Metadata

Assignees

Labels

Area-FSIBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions