From dc8df4de3eb311482e1f7e454df735b4eb5d26a9 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 16 Dec 2022 05:17:14 -0800 Subject: [PATCH 01/13] remove internal restriction --- src/Compiler/AbstractIL/ilsign.fs | 8 +-- src/Compiler/AbstractIL/ilsign.fsi | 4 +- src/Compiler/Driver/CreateILModule.fs | 44 ++++++++------ src/Compiler/Driver/CreateILModule.fsi | 3 + src/Compiler/Interactive/FSIstrings.txt | 1 - src/Compiler/Interactive/fsi.fs | 57 +++++++++---------- .../Interactive/xlf/FSIstrings.txt.cs.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.de.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.es.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.fr.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.it.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.ja.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.ko.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.pl.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.pt-BR.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.ru.xlf | 5 -- .../Interactive/xlf/FSIstrings.txt.tr.xlf | 5 -- .../xlf/FSIstrings.txt.zh-Hans.xlf | 5 -- .../xlf/FSIstrings.txt.zh-Hant.xlf | 5 -- .../Scripting/Interactive.fs | 15 +++++ .../core/printing/output.multiemit.stderr.bsl | 18 ------ 21 files changed, 77 insertions(+), 138 deletions(-) diff --git a/src/Compiler/AbstractIL/ilsign.fs b/src/Compiler/AbstractIL/ilsign.fs index 1fa3a995d50..1d2c21a9cf6 100644 --- a/src/Compiler/AbstractIL/ilsign.fs +++ b/src/Compiler/AbstractIL/ilsign.fs @@ -349,11 +349,11 @@ type ILStrongNameSigner = | KeyPair of keyPair | KeyContainer of keyContainerName - static member OpenPublicKeyOptions s p = - PublicKeyOptionsSigner((signerOpenPublicKeyFile s), p) + static member OpenPublicKeyOptions kp p = + PublicKeyOptionsSigner(kp, p) - static member OpenPublicKey pubkey = PublicKeySigner pubkey - static member OpenKeyPairFile s = KeyPair(signerOpenKeyPairFile s) + static member OpenPublicKey bytes = PublicKeySigner bytes + static member OpenKeyPairFile bytes = KeyPair(bytes) static member OpenKeyContainer s = KeyContainer s member s.IsFullySigned = diff --git a/src/Compiler/AbstractIL/ilsign.fsi b/src/Compiler/AbstractIL/ilsign.fsi index c67980166ab..9dcdbf8ecda 100644 --- a/src/Compiler/AbstractIL/ilsign.fsi +++ b/src/Compiler/AbstractIL/ilsign.fsi @@ -16,9 +16,9 @@ open System.IO [] type ILStrongNameSigner = member PublicKey: byte[] - static member OpenPublicKeyOptions: string -> bool -> ILStrongNameSigner + static member OpenPublicKeyOptions: byte array -> bool -> ILStrongNameSigner static member OpenPublicKey: byte[] -> ILStrongNameSigner - static member OpenKeyPairFile: string -> ILStrongNameSigner + static member OpenKeyPairFile: byte[] -> ILStrongNameSigner static member OpenKeyContainer: string -> ILStrongNameSigner member IsFullySigned: bool member PublicKey: byte[] diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 7aad1268a74..191d806518f 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -65,7 +65,10 @@ module AttributeHelpers = //---------------------------------------------------------------------------- /// Represents the configuration settings used to perform strong-name signing -type StrongNameSigningInfo = StrongNameSigningInfo of delaysign: bool * publicsign: bool * signer: string option * container: string option +type StrongNameSigningInfo = StrongNameSigningInfo of delaysign: bool * publicsign: bool * signer: byte array option * container: string option + +let GetStrongNameSigningInfo (delaysign, publicsign, signer, container) = + StrongNameSigningInfo(delaysign, publicsign, signer, container) /// Validate the attributes and configuration settings used to perform strong-name signing let ValidateKeySigningAttributes (tcConfig: TcConfig, tcGlobals, topAttrs) = @@ -91,14 +94,23 @@ let ValidateKeySigningAttributes (tcConfig: TcConfig, tcGlobals, topAttrs) = // if signer is set via an attribute, validate that it wasn't set via an option let signer = - match signerAttrib with - | Some signer -> - if tcConfig.signer.IsSome && tcConfig.signer <> Some signer then - warning (Error(FSComp.SR.fscKeyFileWarning (), rangeCmdArgs)) - tcConfig.signer - else - Some signer - | None -> tcConfig.signer + let signerFile = + match signerAttrib with + | Some signer -> + if tcConfig.signer.IsSome && tcConfig.signer <> Some signer then + warning (Error(FSComp.SR.fscKeyFileWarning (), rangeCmdArgs)) + tcConfig.signer + else + Some signer + | None -> tcConfig.signer + match signerFile with + | Some signerPath -> + try + Some (FileSystem.OpenFileForReadShim(signerPath).ReadAllBytes()) + with _ -> + // Note :: don't use errorR here since we really want to fail and not produce a binary + error (Error(FSComp.SR.fscKeyFileCouldNotBeOpened signerPath, rangeCmdArgs)) + | None -> None // if container is set via an attribute, validate that it wasn't set via an option, and that they keyfile wasn't set // if keyfile was set, use that instead (silently) @@ -127,15 +139,11 @@ let GetStrongNameSigner signingInfo = | None -> match signer with | None -> None - | Some s -> - try - if publicsign || delaysign then - Some(ILStrongNameSigner.OpenPublicKeyOptions s publicsign) - else - Some(ILStrongNameSigner.OpenKeyPairFile s) - with _ -> - // Note :: don't use errorR here since we really want to fail and not produce a binary - error (Error(FSComp.SR.fscKeyFileCouldNotBeOpened s, rangeCmdArgs)) + | Some bytes -> + if publicsign || delaysign then + Some(ILStrongNameSigner.OpenPublicKeyOptions bytes publicsign) + else + Some(ILStrongNameSigner.OpenKeyPairFile bytes) //---------------------------------------------------------------------------- // Building the contents of the finalized IL module diff --git a/src/Compiler/Driver/CreateILModule.fsi b/src/Compiler/Driver/CreateILModule.fsi index eba0ab0251e..8575a34009d 100644 --- a/src/Compiler/Driver/CreateILModule.fsi +++ b/src/Compiler/Driver/CreateILModule.fsi @@ -15,6 +15,9 @@ open FSharp.Compiler.TypedTree /// Represents the configuration settings used to perform strong-name signing type StrongNameSigningInfo +/// Get the SsigningInfo for specific values(delaysign, tcConfig.publicsign, signer, container) +val GetStrongNameSigningInfo: delaysign: bool * publicsign: bool* signer: byte array option * container: string option -> StrongNameSigningInfo + /// Validate the attributes and configuration settings used to perform strong-name signing val ValidateKeySigningAttributes: tcConfig: TcConfig * tcGlobals: TcGlobals * TopAttribs -> StrongNameSigningInfo diff --git a/src/Compiler/Interactive/FSIstrings.txt b/src/Compiler/Interactive/FSIstrings.txt index 2d41ffcc406..4345a0edc5a 100644 --- a/src/Compiler/Interactive/FSIstrings.txt +++ b/src/Compiler/Interactive/FSIstrings.txt @@ -57,5 +57,4 @@ fsiOperationCouldNotBeCompleted,"Operation could not be completed due to earlier fsiOperationFailed,"Operation failed. The error text has been printed in the error stream. To return the corresponding FSharpDiagnostic use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing" fsiMultiAssemblyEmitOption,"Emit multiple assemblies (on by default)" fsiMultiAssemblyEmitOptionOffByDefault,"Emit multiple assemblies (off by default for .NET Framework)" -2303,fsiInternalAccess,"Accessing the internal type, method or field '%s' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option." 2304,fsiEntryPointWontBeInvoked,"Functions with [] are not invoked in FSI. '%s' was not invoked. Execute '%s ' in order to invoke '%s' with the appropriate string array of command line arguments." diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 0485d4e06e5..e15216e05d4 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -41,6 +41,7 @@ open FSharp.Compiler.CompilerConfig open FSharp.Compiler.CompilerDiagnostics open FSharp.Compiler.CompilerImports open FSharp.Compiler.CompilerGlobalState +open FSharp.Compiler.CreateILModule open FSharp.Compiler.DependencyManager open FSharp.Compiler.Diagnostics open FSharp.Compiler.EditorServices @@ -1360,8 +1361,6 @@ type internal FsiDynamicCompiler( let dynamicCcuName = "FSI-ASSEMBLY" - let maxInternalsVisibleTo = 30 // In multi-assembly emit, how many future interactions can access internals with a warning - let valueBoundEvent = Control.Event<_>() let mutable fragmentId = 0 @@ -1406,44 +1405,29 @@ type internal FsiDynamicCompiler( Some { man with CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs codegenResults.ilAssemAttrs) }) } /// Generate one assembly using multi-assembly emit - let EmitInMemoryAssembly (tcConfig: TcConfig, emEnv: ILMultiInMemoryAssemblyEmitEnv, ilxMainModule: ILModuleDef, m) = + let EmitInMemoryAssembly (tcConfig: TcConfig, emEnv: ILMultiInMemoryAssemblyEmitEnv, ilxMainModule: ILModuleDef) = // The name of the assembly is "FSI-ASSEMBLY1" etc dynamicAssemblyId <- dynamicAssemblyId + 1 - - let multiAssemblyName = ilxMainModule.ManifestOfAssembly.Name + string dynamicAssemblyId + + let multiAssemblyName = ilxMainModule.ManifestOfAssembly.Name // Adjust the assembly name of this fragment, and add InternalsVisibleTo attributes to // allow internals access by multiple future assemblies let manifest = let manifest = ilxMainModule.Manifest.Value - let attrs = - [ for i in 1..maxInternalsVisibleTo do - let fwdAssemblyName = ilxMainModule.ManifestOfAssembly.Name + string (dynamicAssemblyId + i) - tcGlobals.MakeInternalsVisibleToAttribute(fwdAssemblyName) - yield! manifest.CustomAttrs.AsList() ] + let attrs = [ + tcGlobals.MakeInternalsVisibleToAttribute(ilxMainModule.ManifestOfAssembly.Name) + yield! manifest.CustomAttrs.AsList() + ] { manifest with - Name = multiAssemblyName + Name = multiAssemblyName + Version = Some (parseILVersion $"0.0.0.{dynamicAssemblyId}") CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs) } let ilxMainModule = { ilxMainModule with Manifest = Some manifest } - // Check access of internals across fragments and give warning - let refs = computeILRefs ilGlobals ilxMainModule - - for tref in refs.TypeReferences do - if emEnv.IsLocalInternalType(tref) then - warning(Error((FSIstrings.SR.fsiInternalAccess(tref.FullName)), m)) - - for mref in refs.MethodReferences do - if emEnv.IsLocalInternalMethod(mref) then - warning(Error((FSIstrings.SR.fsiInternalAccess(mref.Name)), m)) - - for fref in refs.FieldReferences do - if emEnv.IsLocalInternalField(fref) then - warning(Error((FSIstrings.SR.fsiInternalAccess(fref.Name)), m)) - // Rewrite references to local types to their respective dynamic assemblies let ilxMainModule = ilxMainModule |> Morphs.morphILTypeRefsInILModuleMemoized emEnv.MapTypeRef @@ -1479,6 +1463,7 @@ type internal FsiDynamicCompiler( let assemblyBytes, pdbBytes = WriteILBinaryInMemory (opts, ilxMainModule, normalizeAssemblyRefs) + File.WriteAllBytes($"""c:\temp\FSI-ASSEMBLY-{dynamicAssemblyId}""", assemblyBytes) let asm = match pdbBytes with | None -> Assembly.Load(assemblyBytes) @@ -1563,7 +1548,7 @@ type internal FsiDynamicCompiler( | MultipleInMemoryAssemblies emEnv -> - let execs = EmitInMemoryAssembly (tcConfig, emEnv, ilxMainModule, m) + let execs = EmitInMemoryAssembly (tcConfig, emEnv, ilxMainModule) MultipleInMemoryAssemblies emEnv, execs @@ -1851,8 +1836,14 @@ type internal FsiDynamicCompiler( member _.DynamicAssemblies = dynamicAssemblies.ToArray() - member _.FindDynamicAssembly(simpleAssemName) = - dynamicAssemblies |> ResizeArray.tryFind (fun asm -> asm.GetName().Name = simpleAssemName) + member _.FindDynamicAssembly (name, useFullName: bool) = + let getName (assemblyName: AssemblyName) = + if useFullName then + assemblyName.FullName + else + assemblyName.Name + + dynamicAssemblies |> ResizeArray.tryFind (fun asm -> getName (asm.GetName()) = name) member _.EvalParsedSourceFiles (ctok, diagnosticsLogger, istate, inputs, m) = let i = nextFragmentId() @@ -2469,9 +2460,15 @@ type internal MagicAssemblyResolution () = if simpleAssemName.EndsWith(".XmlSerializers", StringComparison.OrdinalIgnoreCase) || simpleAssemName = "UIAutomationWinforms" then null else - match fsiDynamicCompiler.FindDynamicAssembly(simpleAssemName) with + // Check dynamic assemblies by exact version + match fsiDynamicCompiler.FindDynamicAssembly(fullAssemName, true) with | Some asm -> asm | None -> + // Check dynamic assemblies by simple name + match fsiDynamicCompiler.FindDynamicAssembly(simpleAssemName, false) with + | Some asm -> asm + | None -> + // Otherwise continue let assemblyReferenceTextDll = (simpleAssemName + ".dll") diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf index 667a5ed5a7b..a7c396de030 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf @@ -7,11 +7,6 @@ Funkce s [<EntryPoint>] nejsou vyvolány v FSI. {0} nebylo vyvoláno. Pokud chcete vyvolat {2} s příslušným polem řetězců argumentů příkazového řádku, spusťte příkaz{1} <args>. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - Přístup k internímu typu, metodě nebo poli {0} z předchozího vyhodnocení ve F# Interactive je zastaralý a může způsobit následné chyby přístupu. Pokud chcete povolit starší generaci jednoho dynamického sestavení, které má přístup k interním sestavením, použijte možnost --multiemit-. - - Include package source uri when searching for packages Při vyhledávání balíčků zahrnout identifikátor zdroje balíčku diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf index f6553e896d1..7d50af6d8cf 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf @@ -7,11 +7,6 @@ Funktionen mit [<EntryPoint>] werden in FSI nicht aufgerufen. '{0}' wurde nicht aufgerufen. Führen Sie '{1} <args>' aus, um '{2}' mit dem entsprechenden String-Array von Befehlszeilenargumenten aufzurufen. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - Der Zugriff auf den internen Typ, die Methode oder das Feld “{0}” aus einer vorherigen Auswertung in F# Interactive ist veraltet und kann zu nachfolgenden Zugriffsfehlern führen. Verwenden Sie die Option “--multiemit-”, um die Legacygenerierung einer einzelnen dynamischen Assembly zu aktivieren, die auf Interne zugreifen kann. - - Include package source uri when searching for packages URI der Paketquelle bei Suche nach Paketen einschließen diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf index 913c5217e13..c252574b395 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf @@ -7,11 +7,6 @@ Las funciones con [<EntryPoint>] no se invocan en FSI. “{0}” no se invocó. Ejecute “{1} <args>” para invocar “{2}” con la matriz adecuada de cadenas de argumentos de línea de comandos. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - El acceso al tipo, método o campo interno “{0}” de una evaluación anterior en F# interactivo está en desuso y puede provocar errores de acceso posteriores. Para habilitar la generación heredada de un único ensamblado dinámico que pueda acceder a elementos internos, use la opción “--multiemit-”. - - Include package source uri when searching for packages Incluir el URI de origen del paquete al buscar paquetes diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf index e83c98d04a5..e4afbc50607 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf @@ -7,11 +7,6 @@ Les fonctions avec [<EntryPoint>] ne sont pas appelées dans FSI. '{0}' n’a pas été appelée. Exécutez '{1} <args>' pour appeler '{2}' avec le tableau de chaînes approprié d’arguments de ligne de commande. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - L’accès au type interne, à la méthode ou au champ «{0}» d’une évaluation précédente dans F# Interactive est déconseillé et peut entraîner des erreurs d’accès ultérieures. Pour activer la génération héritée d’un assemblée dynamique unique qui peut accéder aux éléments internes, utilisez l’option « --multiemit- ». - - Include package source uri when searching for packages Inclure l'URI de source de package au moment de la recherche des packages diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf index f59a4e13f44..878cb019824 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf @@ -7,11 +7,6 @@ Le funzioni con [<EntryPoint>] non vengono richiamate in FSI. '{0}' non è stato richiamato. Eseguire '{1} <args>' per richiamare '{2}' con la matrice di stringhe appropriata degli argomenti della riga di comando. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - L'accesso al tipo, al metodo o al campo interno '{0}' da una valutazione precedente in F# Interactive è deprecato e potrebbe causare errori di accesso successivi. Per abilitare la generazione legacy di un singolo assembly dinamico che può accedere agli elementi interni, usare l'opzione '--multiemit-'. - - Include package source uri when searching for packages Includi l'URI di origine pacchetti durante la ricerca di pacchetti diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf index 4bd3f98f44f..17d1861c7d3 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf @@ -7,11 +7,6 @@ [<EntryPoint>] を含む関数は FSI では呼び出されません。'{0}' は呼び出されませんでした。コマンド ライン引数の適切な文字列配列を使用して '{2}' を呼び出すには、'{1} <args>' を実行してください。 - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - F# インタラクティブの以前の評価から内部型、メソッド、またはフィールド `{0}` にアクセスすることは非推奨であり、その後のアクセス エラーが発生する可能性があります。内部にアクセスできる単一の動的アセンブリのレガシ生成を有効にするには、`--multiemit-` オプションを使用します。 - - Include package source uri when searching for packages パッケージの検索時にパッケージ ソースの URI を含める diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf index 5a6c0bb8f4f..52829cee4d3 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf @@ -7,11 +7,6 @@ [<EntryPoint>]가 있는 함수는 FSI에서 호출되지 않습니다. '{0}'이(가) 호출되지 않았습니다. 명령줄 인수의 적절한 문자열 배열로 '{2}'을(를) 호출하려면 '{1}<args>'를 실행하세요. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - F# 대화형의 이전 평가에서 내부 형식, 메서드 또는 필드 '{0}'에 액세스하는 것은 더 이상 사용되지 않으며 후속 액세스 오류가 발생할 수 있습니다. 내부에 액세스할 수 있는 단일 동적 어셈블리의 레거시 생성을 사용하도록 설정하려면 '--multiemit-' 옵션을 사용합니다. - - Include package source uri when searching for packages 패키지를 검색할 때 패키지 원본 URI 포함 diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf index b6cd0fa6659..c530089c64a 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf @@ -7,11 +7,6 @@ Funkcje z elementem [<EntryPoint>] nie są wywoływane w interfejsie FSI. „{0}” nie został wywołany. Wykonaj polecenie „{1} <args>”, aby wywołać „{2}” z odpowiednią tablicą ciągów argumentów wiersza polecenia. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - Uzyskiwanie dostępu do typu wewnętrznego, metody lub pola „{0}“ z poprzedniej oceny w programie F# Interactive jest przestarzałe i może powodować kolejne błędy dostępu. Aby włączyć starszą generację pojedynczego zestawu dynamicznego, który może uzyskiwać dostęp wewnętrzny, użyj opcji „--multiemit-“. - - Include package source uri when searching for packages Uwzględnij identyfikator URI źródła pakietów podczas wyszukiwania pakietów diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf index 3ae204efd46..5434f005526 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf @@ -7,11 +7,6 @@ As funções com [<EntryPoint>] não são invocadas no FSI. '{0}' não foi invocado. Execute '{1} <args>' para invocar '{2}' com a matriz de cadeia de caracteres apropriada dos argumentos da linha de comando. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - O acesso ao tipo, método ou campo interno '{0}' de uma avaliação anterior em F# Interativo é preterido e pode causar erros de acesso subsequentes. Para habilitar a geração herdada de uma única assembly dinâmica que possa acessar os elementos internos, use a opção '--multiemit-'. - - Include package source uri when searching for packages Incluir o URI de origem do pacote ao pesquisar pacotes diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf index 34c69c3e70a..e49a7778fed 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf @@ -7,11 +7,6 @@ Функции с [<EntryPoint>] не вызываются в FSI. "{0}" не вызван. Выполните "{1} <args>", чтобы вызвать "{2}" с соответствующим строковым массивом аргументов командной строки. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - Доступ ко внутреннему типу, методу или полю \"{0}\" из предыдущей оценки в F# Interactive является нерекомендуемым и может привести к последующим ошибкам доступа. Чтобы включить устаревшее создание одной динамической сборки, которая может получать доступ ко внутренним данным, используйте параметр \"--multiemit-\". - - Include package source uri when searching for packages Включать исходный URI пакета при поиске пакетов diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf index e064e5d942c..e5961e2041c 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf @@ -7,11 +7,6 @@ [<EntryPoint>] ile işlevler, FSI'de çağrılmaz. '{0}' başlatılmadı. '{1} <args>' komutunu çalıştırarak uygun komut satırı bağımsız değişken dizisiyle '{2}' komutunu başlatın. - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - F# Etkileşimli’de önceki bir değerlendirmeden '{0}' iç türüne, yöntemine veya alanına erişim kullanım dışıdır ve sonraki erişim hatalarına neden olabilir. İç öğelere erişen tek bir dinamik bütünleştirilmiş kodun eski neslini etkinleştirmek için '--multiemit-' seçeneğini kullanın. - - Include package source uri when searching for packages Paketler aranırken paket kaynağı URI'si ekleyin diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf index e9262eef59c..30c617bb767 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf @@ -7,11 +7,6 @@ FSI 中未调用具有 [<EntryPoint>] 的函数。未调用“{0}”。执行“{1} <args>”,以便使用命令行参数的相应字符串数组调用“{2}”。 - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - 已弃用从 F# 交互窗口的上一个评估中访问内部类型、方法或字段“{0}”,并可能导致后续访问错误。如果要启用可以访问内部的单个动态程序集的旧的生成,请使用 “--multiemit-” 选项。 - - Include package source uri when searching for packages 搜索包时包含包源 uri diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf index 3223a668d89..d38de5f0f82 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf @@ -7,11 +7,6 @@ FSI 中未叫用具有 [<EntryPoint>] 的函數。未叫用'{0}'。執行 '{1} <args>',以使用適當的命令列引數字串陣列叫用 '{2}'。 - - Accessing the internal type, method or field '{0}' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - 從之前 F# 互動中的評估存取內部類型、方法或欄位 '{0}' 已過時,可能造成後續存取錯誤。若要啟用可存取內部之單一動態組件的舊版世代,請使用 '--multiemit-' 選項。 - - Include package source uri when searching for packages 搜尋套件時包含套件來源 URI diff --git a/tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs b/tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs index faf21a9c7a9..cfc86ff3618 100644 --- a/tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs +++ b/tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs @@ -3,6 +3,7 @@ namespace FSharp.Compiler.ComponentTests.Scripting open Xunit +open System open FSharp.Test.Compiler module ``Interactive tests`` = @@ -35,3 +36,17 @@ module ``External FSI tests`` = Fsx "1+a" |> runFsi |> shouldFail + + + [] + let ``Internals visible over a large number of submissions``() = + let submission = + let lines = [| + yield """let internal original_submission = "From the first submission";;""" + Environment.NewLine + for _ in 1 .. 200 do yield """if original_submission <> "From the first submission" then failwith $"Failed to read an internal at line: {__LINE__}";;""" + Environment.NewLine + |] + lines |> Array.fold(fun acc line -> acc + line) "" + Fsx submission + |> runFsi + |> shouldSucceed + diff --git a/tests/fsharp/core/printing/output.multiemit.stderr.bsl b/tests/fsharp/core/printing/output.multiemit.stderr.bsl index 68785a152df..6926dcc9f34 100644 --- a/tests/fsharp/core/printing/output.multiemit.stderr.bsl +++ b/tests/fsharp/core/printing/output.multiemit.stderr.bsl @@ -346,21 +346,3 @@ stdin(838,6): error FS1210: Active pattern '|A|B|' has a result type containing stdin(844,6): error FS1209: Active pattern '|A|B|' is not a function - - let internal f() = 1;; f();; // should give a warning in multi-assembly interactive emit - -----------------------^^^ - -stdin(1089,24): warning FS2303: Accessing the internal type, method or field 'f' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - - - CPublic().MInternal();; // should give a warning in multi-assembly interactive emit - ^^^^^^^^^^^^^^^^^^^^^ - -stdin(1099,1): warning FS2303: Accessing the internal type, method or field 'MInternal' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - - - CPublic2().MPublic();; // should give a warning in multi-assembly interactive emit - ^^^^^^^^^^^^^^^^^^^^ - -stdin(1105,1): warning FS2303: Accessing the internal type, method or field 'MPublic' from a previous evaluation in F# Interactive is deprecated and may cause subsequent access errors. To enable the legacy generation of a single dynamic assembly that can access internals, use the '--multiemit-' option. - From 3a5127353f474da581aaafc7be5a25e9fa4a2514 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 16 Dec 2022 05:32:43 -0800 Subject: [PATCH 02/13] fantomas --- src/Compiler/AbstractIL/ilsign.fs | 3 +-- src/Compiler/Driver/CreateILModule.fs | 6 ++++-- src/Compiler/Driver/CreateILModule.fsi | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Compiler/AbstractIL/ilsign.fs b/src/Compiler/AbstractIL/ilsign.fs index 1d2c21a9cf6..c568da7ade6 100644 --- a/src/Compiler/AbstractIL/ilsign.fs +++ b/src/Compiler/AbstractIL/ilsign.fs @@ -349,8 +349,7 @@ type ILStrongNameSigner = | KeyPair of keyPair | KeyContainer of keyContainerName - static member OpenPublicKeyOptions kp p = - PublicKeyOptionsSigner(kp, p) + static member OpenPublicKeyOptions kp p = PublicKeyOptionsSigner(kp, p) static member OpenPublicKey bytes = PublicKeySigner bytes static member OpenKeyPairFile bytes = KeyPair(bytes) diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 191d806518f..60c588263e4 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -65,7 +65,8 @@ module AttributeHelpers = //---------------------------------------------------------------------------- /// Represents the configuration settings used to perform strong-name signing -type StrongNameSigningInfo = StrongNameSigningInfo of delaysign: bool * publicsign: bool * signer: byte array option * container: string option +type StrongNameSigningInfo = + | StrongNameSigningInfo of delaysign: bool * publicsign: bool * signer: byte array option * container: string option let GetStrongNameSigningInfo (delaysign, publicsign, signer, container) = StrongNameSigningInfo(delaysign, publicsign, signer, container) @@ -103,10 +104,11 @@ let ValidateKeySigningAttributes (tcConfig: TcConfig, tcGlobals, topAttrs) = else Some signer | None -> tcConfig.signer + match signerFile with | Some signerPath -> try - Some (FileSystem.OpenFileForReadShim(signerPath).ReadAllBytes()) + Some(FileSystem.OpenFileForReadShim(signerPath).ReadAllBytes()) with _ -> // Note :: don't use errorR here since we really want to fail and not produce a binary error (Error(FSComp.SR.fscKeyFileCouldNotBeOpened signerPath, rangeCmdArgs)) diff --git a/src/Compiler/Driver/CreateILModule.fsi b/src/Compiler/Driver/CreateILModule.fsi index 8575a34009d..90608e324e5 100644 --- a/src/Compiler/Driver/CreateILModule.fsi +++ b/src/Compiler/Driver/CreateILModule.fsi @@ -16,7 +16,8 @@ open FSharp.Compiler.TypedTree type StrongNameSigningInfo /// Get the SsigningInfo for specific values(delaysign, tcConfig.publicsign, signer, container) -val GetStrongNameSigningInfo: delaysign: bool * publicsign: bool* signer: byte array option * container: string option -> StrongNameSigningInfo +val GetStrongNameSigningInfo: + delaysign: bool * publicsign: bool * signer: byte array option * container: string option -> StrongNameSigningInfo /// Validate the attributes and configuration settings used to perform strong-name signing val ValidateKeySigningAttributes: tcConfig: TcConfig * tcGlobals: TcGlobals * TopAttribs -> StrongNameSigningInfo From 6e5fc24777f87558868732d18c259b789750b8fe Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 16 Dec 2022 05:46:20 -0800 Subject: [PATCH 03/13] Oops --- src/Compiler/Interactive/fsi.fs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index e15216e05d4..77a17076202 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1463,7 +1463,6 @@ type internal FsiDynamicCompiler( let assemblyBytes, pdbBytes = WriteILBinaryInMemory (opts, ilxMainModule, normalizeAssemblyRefs) - File.WriteAllBytes($"""c:\temp\FSI-ASSEMBLY-{dynamicAssemblyId}""", assemblyBytes) let asm = match pdbBytes with | None -> Assembly.Load(assemblyBytes) From b6bf8846e7cb19795f205e449cb04272f7ae6fe1 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 16 Dec 2022 10:12:26 -0800 Subject: [PATCH 04/13] Update src/Compiler/Interactive/fsi.fs Co-authored-by: Tomas Grosup --- src/Compiler/Interactive/fsi.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 77a17076202..907e70366fc 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1413,7 +1413,7 @@ type internal FsiDynamicCompiler( let multiAssemblyName = ilxMainModule.ManifestOfAssembly.Name // Adjust the assembly name of this fragment, and add InternalsVisibleTo attributes to - // allow internals access by multiple future assemblies + // allow internals access by all future assemblies with the same name (and only differing in version) let manifest = let manifest = ilxMainModule.Manifest.Value let attrs = [ From a504315d8d44a99a7a87532644bb15f8fab3488f Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 16 Dec 2022 10:13:05 -0800 Subject: [PATCH 05/13] Update src/Compiler/Interactive/fsi.fs Co-authored-by: Tomas Grosup --- src/Compiler/Interactive/fsi.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 907e70366fc..0b0b149245f 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1407,7 +1407,7 @@ type internal FsiDynamicCompiler( /// Generate one assembly using multi-assembly emit let EmitInMemoryAssembly (tcConfig: TcConfig, emEnv: ILMultiInMemoryAssemblyEmitEnv, ilxMainModule: ILModuleDef) = - // The name of the assembly is "FSI-ASSEMBLY1" etc + // The name of the assembly is "FSI-ASSEMBLY" for all submissions. This number is used for the Version dynamicAssemblyId <- dynamicAssemblyId + 1 let multiAssemblyName = ilxMainModule.ManifestOfAssembly.Name From 848571e311378bc9d6c81ea6372877d2521ad023 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 16 Dec 2022 11:45:57 -0800 Subject: [PATCH 06/13] make desktop fsi default to multi-emit --- src/Compiler/Interactive/FSIstrings.txt | 1 - src/Compiler/Interactive/fsi.fs | 35 +++++++------------ .../Interactive/xlf/FSIstrings.txt.cs.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.de.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.es.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.fr.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.it.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.ja.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.ko.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.pl.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.pt-BR.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.ru.xlf | 5 --- .../Interactive/xlf/FSIstrings.txt.tr.xlf | 5 --- .../xlf/FSIstrings.txt.zh-Hans.xlf | 5 --- .../xlf/FSIstrings.txt.zh-Hant.xlf | 5 --- .../fsi/exename/help40.437.1033.bsl | 4 +-- .../fsi/help/help40-nologo.437.1033.bsl | 4 +-- .../fsi/help/help40.437.1033.bsl | 4 +-- 18 files changed, 19 insertions(+), 94 deletions(-) diff --git a/src/Compiler/Interactive/FSIstrings.txt b/src/Compiler/Interactive/FSIstrings.txt index 4345a0edc5a..c357f835be5 100644 --- a/src/Compiler/Interactive/FSIstrings.txt +++ b/src/Compiler/Interactive/FSIstrings.txt @@ -56,5 +56,4 @@ shadowCopyReferences,"Prevents references from being locked by the F# Interactiv fsiOperationCouldNotBeCompleted,"Operation could not be completed due to earlier error" fsiOperationFailed,"Operation failed. The error text has been printed in the error stream. To return the corresponding FSharpDiagnostic use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing" fsiMultiAssemblyEmitOption,"Emit multiple assemblies (on by default)" -fsiMultiAssemblyEmitOptionOffByDefault,"Emit multiple assemblies (off by default for .NET Framework)" 2304,fsiEntryPointWontBeInvoked,"Functions with [] are not invoked in FSI. '%s' was not invoked. Execute '%s ' in order to invoke '%s' with the appropriate string array of command line arguments." diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 0b0b149245f..fc9bf109373 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -939,31 +939,22 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, ] /// These options follow the FsiCoreCompilerOptions in the help blocks - let fsiUsageSuffix tcConfigB = - [PublicOptions(FSComp.SR.optsHelpBannerInputFiles(), - [CompilerOption("--","", OptionRest recordExplicitArg, None, - Some (FSIstrings.SR.fsiRemaining())); - ]); - PublicOptions(FSComp.SR.optsHelpBannerMisc(), - [ CompilerOption("help", tagNone, - OptionConsoleOnly (displayHelpFsi tcConfigB), None, Some (FSIstrings.SR.fsiHelp())) - ]); - PrivateOptions( - [ CompilerOption("?", tagNone, OptionConsoleOnly (displayHelpFsi tcConfigB), None, None); // "Short form of --help"); + let fsiUsageSuffix tcConfigB = [ + PublicOptions(FSComp.SR.optsHelpBannerInputFiles(), [CompilerOption("--","", OptionRest recordExplicitArg, None, Some (FSIstrings.SR.fsiRemaining())); ]); + PublicOptions(FSComp.SR.optsHelpBannerMisc(), [ CompilerOption("help", tagNone, OptionConsoleOnly (displayHelpFsi tcConfigB), None, Some (FSIstrings.SR.fsiHelp())) ]); + PrivateOptions([ + CompilerOption("?", tagNone, OptionConsoleOnly (displayHelpFsi tcConfigB), None, None); // "Short form of --help"); CompilerOption("help", tagNone, OptionConsoleOnly (displayHelpFsi tcConfigB), None, None); // "Short form of --help"); CompilerOption("full-help", tagNone, OptionConsoleOnly (displayHelpFsi tcConfigB), None, None); // "Short form of --help"); ]); - PublicOptions(FSComp.SR.optsHelpBannerAdvanced(), - [CompilerOption("exec", "", OptionUnit (fun () -> interact <- false), None, Some (FSIstrings.SR.fsiExec())) - CompilerOption("gui", tagNone, OptionSwitch(fun flag -> gui <- (flag = OptionSwitch.On)),None,Some (FSIstrings.SR.fsiGui())) - CompilerOption("quiet", "", OptionUnit (fun () -> tcConfigB.noFeedback <- true), None,Some (FSIstrings.SR.fsiQuiet())); - CompilerOption("readline", tagNone, OptionSwitch(fun flag -> enableConsoleKeyProcessing <- (flag = OptionSwitch.On)), None, Some(FSIstrings.SR.fsiReadline())) - CompilerOption("quotations-debug", tagNone, OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On),None, Some(FSIstrings.SR.fsiEmitDebugInfoInQuotations())) - CompilerOption("shadowcopyreferences", tagNone, OptionSwitch(fun flag -> tcConfigB.shadowCopyReferences <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.shadowCopyReferences())) - if FSharpEnvironment.isRunningOnCoreClr then - CompilerOption("multiemit", tagNone, OptionSwitch(fun flag -> tcConfigB.fsiMultiAssemblyEmit <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.fsiMultiAssemblyEmitOption())) - else - CompilerOption("multiemit", tagNone, OptionSwitch(fun flag -> tcConfigB.fsiMultiAssemblyEmit <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.fsiMultiAssemblyEmitOptionOffByDefault())) + PublicOptions(FSComp.SR.optsHelpBannerAdvanced(), [ + CompilerOption("exec", "", OptionUnit (fun () -> interact <- false), None, Some (FSIstrings.SR.fsiExec())) + CompilerOption("gui", tagNone, OptionSwitch(fun flag -> gui <- (flag = OptionSwitch.On)),None,Some (FSIstrings.SR.fsiGui())) + CompilerOption("quiet", "", OptionUnit (fun () -> tcConfigB.noFeedback <- true), None,Some (FSIstrings.SR.fsiQuiet())); + CompilerOption("readline", tagNone, OptionSwitch(fun flag -> enableConsoleKeyProcessing <- (flag = OptionSwitch.On)), None, Some(FSIstrings.SR.fsiReadline())) + CompilerOption("quotations-debug", tagNone, OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On),None, Some(FSIstrings.SR.fsiEmitDebugInfoInQuotations())) + CompilerOption("shadowcopyreferences", tagNone, OptionSwitch(fun flag -> tcConfigB.shadowCopyReferences <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.shadowCopyReferences())) + CompilerOption("multiemit", tagNone, OptionSwitch(fun flag -> tcConfigB.fsiMultiAssemblyEmit <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.fsiMultiAssemblyEmitOption())) ]); ] diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf index a7c396de030..97dcca71c4c 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf @@ -17,11 +17,6 @@ Vymazat obrazovku - - Emit multiple assemblies (off by default for .NET Framework) - Vygenerovat více sestavení (pro .NET Framework je to ve výchozím nastavení vypnuto) - - Operation could not be completed due to earlier error Operaci nešlo dokončit z důvodu dřívější chyby. diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf index 7d50af6d8cf..a3d73b0e675 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf @@ -17,11 +17,6 @@ Bildschirm löschen - - Emit multiple assemblies (off by default for .NET Framework) - Ausgeben mehrerer Assemblys (standardmäßig deaktiviert für .NET Framework) - - Operation could not be completed due to earlier error Der Vorgang konnte aufgrund eines vorherigen Fehlers nicht abgeschlossen werden. diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf index c252574b395..190ff245baa 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf @@ -17,11 +17,6 @@ Borrar pantalla - - Emit multiple assemblies (off by default for .NET Framework) - Emitir varios ensamblados (desactivado de forma predeterminada para .NET Framework) - - Operation could not be completed due to earlier error La operación no se pudo completar debido a un error anterior diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf index e4afbc50607..38d7a20d8e9 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf @@ -17,11 +17,6 @@ Effacer l'écran - - Emit multiple assemblies (off by default for .NET Framework) - Émettre plusieurs assemblées (désactivé par défaut pour .NET Framework) - - Operation could not be completed due to earlier error Impossible d'exécuter l'opération en raison d'une erreur antérieure diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf index 878cb019824..9c916837e52 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf @@ -17,11 +17,6 @@ Cancella schermata - - Emit multiple assemblies (off by default for .NET Framework) - Creare più assembly (disattivato per impostazione predefinita per .NET Framework) - - Operation could not be completed due to earlier error Non è stato possibile completare l'operazione a causa di un errore precedente diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf index 17d1861c7d3..eab626f267e 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf @@ -17,11 +17,6 @@ 画面をクリアする - - Emit multiple assemblies (off by default for .NET Framework) - 複数のアセンブリを出力する (.NET Frameworkの場合は既定でオフ) - - Operation could not be completed due to earlier error 以前のエラーが原因で操作を完了できませんでした diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf index 52829cee4d3..be891b98188 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf @@ -17,11 +17,6 @@ 화면 지우기 - - Emit multiple assemblies (off by default for .NET Framework) - 여러 어셈블리 내보내기(기본적으로 .NET Framework 해제) - - Operation could not be completed due to earlier error 이전 오류로 인해 작업을 완료할 수 없습니다. diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf index c530089c64a..58adec37da4 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf @@ -17,11 +17,6 @@ Wyczyść ekran - - Emit multiple assemblies (off by default for .NET Framework) - Emituj wiele zestawów (domyślnie wyłączone dla programu .NET Framework) - - Operation could not be completed due to earlier error Nie udało się ukończyć operacji z powodu wcześniejszego błędu diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf index 5434f005526..b080a196f7c 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf @@ -17,11 +17,6 @@ Limpar tela - - Emit multiple assemblies (off by default for .NET Framework) - Emitir várias montagens (desligadas por padrão para .NET Framework) - - Operation could not be completed due to earlier error Não foi possível concluir a operação devido a um erro anterior diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf index e49a7778fed..e46822530d8 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf @@ -17,11 +17,6 @@ Очистить экран - - Emit multiple assemblies (off by default for .NET Framework) - Выпуск нескольких сборок (отключено по умолчанию для .NET Framework) - - Operation could not be completed due to earlier error Операция не может быть завершена из-за предыдущей ошибки diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf index e5961e2041c..3222a474ef5 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf @@ -17,11 +17,6 @@ Ekranı temizle - - Emit multiple assemblies (off by default for .NET Framework) - Birden çok bütünleştirilmiş kod göster (.NET Framework için varsayılan olarak kapalı) - - Operation could not be completed due to earlier error Önceki hata nedeniyle işlem tamamlanamadı diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf index 30c617bb767..de485cc5361 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf @@ -17,11 +17,6 @@ 清除屏幕 - - Emit multiple assemblies (off by default for .NET Framework) - 发出多个程序集(默认情况下为 .NET Framework 关闭) - - Operation could not be completed due to earlier error 由于早期错误,无法完成操作 diff --git a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf index d38de5f0f82..9348019132b 100644 --- a/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf +++ b/src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf @@ -17,11 +17,6 @@ 清空螢幕 - - Emit multiple assemblies (off by default for .NET Framework) - 發出多組件 (.NET Framework 預設為關閉) - - Operation could not be completed due to earlier error 因為先前發生錯誤,所以無法完成作業 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/help40.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/exename/help40.437.1033.bsl index 623a47f3f1a..230f80b709e 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/help40.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/exename/help40.437.1033.bsl @@ -107,5 +107,5 @@ Usage: fsharpi [script.fsx []] --quotations-debug[+|-] Emit debug information in quotations --shadowcopyreferences[+|-] Prevents references from being locked by the F# Interactive process ---multiemit[+|-] Emit multiple assemblies (off by - default for .NET Framework) \ No newline at end of file +--multiemit[+|-] Emit multiple assemblies (on by + default) \ No newline at end of file diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl index c52df3651b3..b0d97ddcd12 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl @@ -107,5 +107,5 @@ Usage: fsiAnyCpu [script.fsx []] --quotations-debug[+|-] Emit debug information in quotations --shadowcopyreferences[+|-] Prevents references from being locked by the F# Interactive process ---multiemit[+|-] Emit multiple assemblies (off by - default for .NET Framework) \ No newline at end of file +--multiemit[+|-] Emit multiple assemblies (on by + default) \ No newline at end of file diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl index 0da770a2436..e95a139b5fb 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl @@ -109,5 +109,5 @@ Usage: fsiAnyCpu [script.fsx []] --quotations-debug[+|-] Emit debug information in quotations --shadowcopyreferences[+|-] Prevents references from being locked by the F# Interactive process ---multiemit[+|-] Emit multiple assemblies (off by - default for .NET Framework) \ No newline at end of file +--multiemit[+|-] Emit multiple assemblies (on by + default) \ No newline at end of file From 51b73bb727c76b0a34940e5e370c19387610c210 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 20 Dec 2022 08:52:13 -0800 Subject: [PATCH 07/13] fix some issues --- a | Bin 0 -> 272 bytes src/Compiler/Driver/CreateILModule.fsi | 2 +- src/Compiler/Interactive/fsi.fs | 38 +++++----- tests/FSharp.Compiler.UnitTests/FsiTests.fs | 77 ++++++++++++-------- 4 files changed, 65 insertions(+), 52 deletions(-) create mode 100644 a diff --git a/a b/a new file mode 100644 index 0000000000000000000000000000000000000000..6ff3473cd9a3bb99103da142d5f08d1fbdc6f653 GIT binary patch literal 272 zcmXAj+X?|;6otQQ-XJ|a_2N(r%1DBsA5dbTPtgzXV>dn Ws StrongNameSigningInfo diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index fc9bf109373..69a5f684b05 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1380,8 +1380,6 @@ type internal FsiDynamicCompiler( let rangeStdin0 = rangeN stdinMockFileName 0 - //let _writer = moduleBuilder.GetSymWriter() - let infoReader = InfoReader(tcGlobals,tcImports.GetImportMap()) let reportedAssemblies = Dictionary() @@ -1413,7 +1411,8 @@ type internal FsiDynamicCompiler( ] { manifest with Name = multiAssemblyName - Version = Some (parseILVersion $"0.0.0.{dynamicAssemblyId}") + // Because the coreclr loader will not load a higher assembly make versions go downwards + Version = Some (parseILVersion $"0.0.0.{5000 - dynamicAssemblyId}") CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs) } @@ -1476,18 +1475,23 @@ type internal FsiDynamicCompiler( yield! loop (enc@[tdef]) ntdef ] [ for tdef in ilxMainModule.TypeDefs do yield! loop [] tdef ] - // Make the 'exec' functions for the entry point initializations - let execs = + let execs = [ for edef in entries do if edef.ArgCount = 0 then - yield - (fun () -> + yield (fun () -> let typ = asm.GetType(edef.DeclaringTypeRef.BasicQualifiedName) try ignore (typ.InvokeMember (edef.Name, BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static, null, null, [| |], Globalization.CultureInfo.InvariantCulture)) None - with :? TargetInvocationException as e -> - Some e.InnerException) ] + with + //| :? TargetInvocationException as e when e.InnerException.GetType() = typeof -> + // ignore (typ.InvokeMember (edef.Name, BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static, null, null, [| |], Globalization.CultureInfo.InvariantCulture)) + // File.WriteAllBytes($"""c:\temp\FSI-ASSEMBLY-{dynamicAssemblyId} - {Guid.NewGuid()}""", assemblyBytes) + // None + // //Some e.InnerException + | :? TargetInvocationException as e -> + Some e.InnerException) + ] emEnv.AddModuleDef asm ilScopeRef ilxMainModule @@ -1707,11 +1711,10 @@ type internal FsiDynamicCompiler( let nextFragmentId() = fragmentId <- fragmentId + 1 - fragmentId + $"%04d{fragmentId}" - let mkFragmentPath m i = - // NOTE: this text shows in exn traces and type names. Make it clear and fixed width - [mkSynId m (FsiDynamicModulePrefix + sprintf "%04d" i)] + let mkFragmentPath m fragmentId = + [mkSynId m (FsiDynamicModulePrefix + fragmentId())] let processContents istate declaredImpls = let tcState = istate.tcState @@ -1836,8 +1839,7 @@ type internal FsiDynamicCompiler( dynamicAssemblies |> ResizeArray.tryFind (fun asm -> getName (asm.GetName()) = name) member _.EvalParsedSourceFiles (ctok, diagnosticsLogger, istate, inputs, m) = - let i = nextFragmentId() - let prefix = mkFragmentPath m i + let prefix = mkFragmentPath m nextFragmentId // Ensure the path includes the qualifying name let inputs = inputs |> List.map (PrependPathToInput prefix) let isIncrementalFragment = false @@ -1847,9 +1849,8 @@ type internal FsiDynamicCompiler( /// Evaluate the given definitions and produce a new interactive state. member _.EvalParsedDefinitions (ctok, diagnosticsLogger: DiagnosticsLogger, istate, showTypes, isInteractiveItExpr, defs: SynModuleDecl list) = let fileName = stdinMockFileName - let i = nextFragmentId() let m = match defs with [] -> rangeStdin0 | _ -> List.reduce unionRanges [for d in defs -> d.Range] - let prefix = mkFragmentPath m i + let prefix = mkFragmentPath m nextFragmentId let prefixPath = pathOfLid prefix let impl = SynModuleOrNamespace(prefix,false, SynModuleOrNamespaceKind.NamedModule,defs,PreXmlDoc.Empty,[],None,m, { LeadingKeyword = SynModuleOrNamespaceLeadingKeyword.None }) let isLastCompiland = true @@ -2203,9 +2204,8 @@ type internal FsiDynamicCompiler( let ty = List.head tys let amap = istate.tcImports.GetImportMap() - let i = nextFragmentId() let m = rangeStdin0 - let prefix = mkFragmentPath m i + let prefix = mkFragmentPath m nextFragmentId let prefixPath = pathOfLid prefix let qualifiedName = ComputeQualifiedNameOfFileFromUniquePath (m,prefixPath) diff --git a/tests/FSharp.Compiler.UnitTests/FsiTests.fs b/tests/FSharp.Compiler.UnitTests/FsiTests.fs index 36b36a1c49f..0aed7bbb74a 100644 --- a/tests/FSharp.Compiler.UnitTests/FsiTests.fs +++ b/tests/FSharp.Compiler.UnitTests/FsiTests.fs @@ -14,7 +14,7 @@ type Sentinel () = module MyModule = let test(x: int) = () -[] +[] module FsiTests = let createFsiSession (useOneDynamicAssembly: bool) = @@ -646,35 +646,48 @@ module FsiTests = #if NETCOREAPP [] - let ``Evaluating simple reference and code succeeds under permutations``() = - - for useSdkRefsFlag in ["/usesdkrefs"; "/usesdkrefs-"] do - for multiemitFlag in ["/multiemit"; "/multiemit-"] do - let config = FsiEvaluationSession.GetDefaultConfiguration() - let argv = [| - typeof.Assembly.Location - "--noninteractive" - "--targetprofile:netcore" - "--langversion:preview" - multiemitFlag - useSdkRefsFlag - |] - let fsi = FsiEvaluationSession.Create(config, argv, TextReader.Null, TextWriter.Null, TextWriter.Null) - let assemblyPath = typeof.Assembly.Location.Replace("\\", "/") - let code = $@" - #r ""{assemblyPath}"" - FSharp.Compiler.UnitTests.MyModule.test(3)" - let ch, errors = fsi.EvalInteractionNonThrowing(code, CancellationToken.None) - errors - |> Array.iter (fun e -> printfn "error: %A" e) - match ch with - | Choice1Of2 v -> - let v = - match v with - | Some v -> sprintf "%A" v.ReflectionValue - | None -> "(none)" - printfn "value: %A" v - | Choice2Of2 e -> - printfn "exception: %A" e - raise e + let ``Evaluating simple reference and code succeeds with multiemit on``() = + + use fsiSession = createFsiSession false + let assemblyPath = typeof.Assembly.Location.Replace("\\", "/") + let res, errors = fsiSession.EvalInteractionNonThrowing($""" + #r "{assemblyPath}" + FSharp.Compiler.UnitTests.MyModule.test(3)""") + + errors + |> Array.iter (fun e -> printfn "error: %A" e) + + match res with + | Choice1Of2 v -> + let v = + match v with + | Some v -> sprintf "%A" v.ReflectionValue + | None -> "(none)" + printfn "value: %A" v + | Choice2Of2 e -> + printfn "exception: %A" e + raise e + + [] + let ``Evaluating simple reference and code succeeds with multiemit off``() = + + use fsiSession = createFsiSession true + let assemblyPath = typeof.Assembly.Location.Replace("\\", "/") + let res, errors = fsiSession.EvalInteractionNonThrowing($""" + #r "{assemblyPath}" + FSharp.Compiler.UnitTests.MyModule.test(3)""") + + errors + |> Array.iter (fun e -> printfn "error: %A" e) + + match res with + | Choice1Of2 v -> + let v = + match v with + | Some v -> sprintf "%A" v.ReflectionValue + | None -> "(none)" + printfn "value: %A" v + | Choice2Of2 e -> + printfn "exception: %A" e + raise e #endif From 39f326b8f9dd4192851dcd0d5338b052fa91e069 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 20 Dec 2022 09:40:26 -0800 Subject: [PATCH 08/13] ushort --- src/Compiler/Interactive/fsi.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 69a5f684b05..de656de754f 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1412,7 +1412,7 @@ type internal FsiDynamicCompiler( { manifest with Name = multiAssemblyName // Because the coreclr loader will not load a higher assembly make versions go downwards - Version = Some (parseILVersion $"0.0.0.{5000 - dynamicAssemblyId}") + Version = Some (parseILVersion $"0.0.0.{UInt16.MaxValue - uint16(dynamicAssemblyId)}") CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs) } From ad928340788e0daf0f710db221b8c19ed8f82bf5 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Tue, 20 Dec 2022 10:19:53 -0800 Subject: [PATCH 09/13] commented out code --- src/Compiler/Interactive/fsi.fs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index de656de754f..24e2302421b 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1484,11 +1484,6 @@ type internal FsiDynamicCompiler( ignore (typ.InvokeMember (edef.Name, BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static, null, null, [| |], Globalization.CultureInfo.InvariantCulture)) None with - //| :? TargetInvocationException as e when e.InnerException.GetType() = typeof -> - // ignore (typ.InvokeMember (edef.Name, BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static, null, null, [| |], Globalization.CultureInfo.InvariantCulture)) - // File.WriteAllBytes($"""c:\temp\FSI-ASSEMBLY-{dynamicAssemblyId} - {Guid.NewGuid()}""", assemblyBytes) - // None - // //Some e.InnerException | :? TargetInvocationException as e -> Some e.InnerException) ] From 302c5025929360f96ba7eea33fe6d50c4e3385f9 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Tue, 20 Dec 2022 12:51:46 -0800 Subject: [PATCH 10/13] Correct size for maxvalue --- src/Compiler/Interactive/fsi.fs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 24e2302421b..9484874858d 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1412,7 +1412,7 @@ type internal FsiDynamicCompiler( { manifest with Name = multiAssemblyName // Because the coreclr loader will not load a higher assembly make versions go downwards - Version = Some (parseILVersion $"0.0.0.{UInt16.MaxValue - uint16(dynamicAssemblyId)}") + Version = Some (parseILVersion $"0.0.0.{uint16(Int16.MaxValue) - uint16(dynamicAssemblyId)}") CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs) } @@ -3388,10 +3388,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i do if isRunningOnCoreClr then SetTargetProfile tcConfigB "netcore" // always assume System.Runtime codegen #endif - // Preset: --multiemit- on .NET Framework and Mono - do if not isRunningOnCoreClr then - tcConfigB.fsiMultiAssemblyEmit <- false - // Preset: --optimize+ -g --tailcalls+ (see 4505) do SetOptimizeSwitch tcConfigB OptionSwitch.On do SetDebugSwitch tcConfigB (Some "pdbonly") OptionSwitch.On From 0d90a1a4b8b614c241c9b8cf0665941a2efaa8fa Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Tue, 20 Dec 2022 14:37:23 -0800 Subject: [PATCH 11/13] tweak --- src/Compiler/Interactive/fsi.fs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 9484874858d..93796a4560e 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1355,9 +1355,9 @@ type internal FsiDynamicCompiler( let valueBoundEvent = Control.Event<_>() let mutable fragmentId = 0 - static let mutable dynamicAssemblyId = 0 - + static let maxVersion = int Int16.MaxValue + let mutable prevIt : ValRef option = None let dynamicAssemblies = ResizeArray() @@ -1395,10 +1395,6 @@ type internal FsiDynamicCompiler( /// Generate one assembly using multi-assembly emit let EmitInMemoryAssembly (tcConfig: TcConfig, emEnv: ILMultiInMemoryAssemblyEmitEnv, ilxMainModule: ILModuleDef) = - - // The name of the assembly is "FSI-ASSEMBLY" for all submissions. This number is used for the Version - dynamicAssemblyId <- dynamicAssemblyId + 1 - let multiAssemblyName = ilxMainModule.ManifestOfAssembly.Name // Adjust the assembly name of this fragment, and add InternalsVisibleTo attributes to @@ -1412,10 +1408,13 @@ type internal FsiDynamicCompiler( { manifest with Name = multiAssemblyName // Because the coreclr loader will not load a higher assembly make versions go downwards - Version = Some (parseILVersion $"0.0.0.{uint16(Int16.MaxValue) - uint16(dynamicAssemblyId)}") + Version = Some (parseILVersion $"0.0.0.{maxVersion - dynamicAssemblyId}") CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs) } + // The name of the assembly is "FSI-ASSEMBLY" for all submissions. This number is used for the Version + dynamicAssemblyId <- (dynamicAssemblyId + 1) % maxVersion + let ilxMainModule = { ilxMainModule with Manifest = Some manifest } // Rewrite references to local types to their respective dynamic assemblies @@ -1457,7 +1456,6 @@ type internal FsiDynamicCompiler( match pdbBytes with | None -> Assembly.Load(assemblyBytes) | Some pdbBytes -> Assembly.Load(assemblyBytes, pdbBytes) - dynamicAssemblies.Add(asm) let loadedTypes = [ for t in asm.GetTypes() -> t] From e4069119a6563bc38e9a99cb04011787f1e1246e Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 20 Dec 2022 21:48:55 -0800 Subject: [PATCH 12/13] No longer a compile error under fsi with multiemit --- .../Misc/E_InheritClassWithoutDefCtor.fs | 19 ------------------- .../Source/InteractiveSession/Misc/env.lst | 2 -- 2 files changed, 21 deletions(-) delete mode 100644 tests/fsharpqa/Source/InteractiveSession/Misc/E_InheritClassWithoutDefCtor.fs diff --git a/tests/fsharpqa/Source/InteractiveSession/Misc/E_InheritClassWithoutDefCtor.fs b/tests/fsharpqa/Source/InteractiveSession/Misc/E_InheritClassWithoutDefCtor.fs deleted file mode 100644 index 8fb0dc6abd8..00000000000 --- a/tests/fsharpqa/Source/InteractiveSession/Misc/E_InheritClassWithoutDefCtor.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Regression #NoMT #FSI -// Regression test for FSharp1.0:1626 - Classes without constructors can't be emitted by Reflection.Emit. This causes late error in compilation -// Parent does not have a default constructor\. The default constructor must be explicitly defined - -type B = class - - new(a:int) = {} - -end - -type C = class - inherit B -end - -#if INTERACTIVE -;; -exit 1;; -#endif - diff --git a/tests/fsharpqa/Source/InteractiveSession/Misc/env.lst b/tests/fsharpqa/Source/InteractiveSession/Misc/env.lst index c3cf858c21b..ef48ada5cfa 100644 --- a/tests/fsharpqa/Source/InteractiveSession/Misc/env.lst +++ b/tests/fsharpqa/Source/InteractiveSession/Misc/env.lst @@ -74,8 +74,6 @@ NOMONO SOURCE=References40.fsx COMPILE_ONLY=1 FSIMODE=PIPE SCFLAGS="--nologo" # SOURCE=DefinesCompiled.fs # DefinesCompiled SOURCE=E_ErrorRanges01.fs COMPILE_ONLY=1 FSIMODE=PIPE # E_ErrorRanges01.fs - SOURCE=E_InheritClassWithoutDefCtor.fs COMPILE_ONLY=1 FSIMODE=PIPE # E_InheritClassWithoutDefCtor.fs - SOURCE=DoWithNotUnit.fs COMPILE_ONLY=1 FSIMODE=PIPE # DoWithNotUnit.fs SOURCE=LoadingFsx.fsx COMPILE_ONLY=1 FSIMODE=PIPE SCFLAGS="--test:ErrorRanges" # LoadingFsx.fsx SOURCE=LoadingFsx.fsscript COMPILE_ONLY=1 FSIMODE=PIPE SCFLAGS="--test:ErrorRanges" # LoadingFsx.fsscript From 093e444e31cbccd29acc91c144cf1b28a441ff9e Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Wed, 21 Dec 2022 01:32:38 -0800 Subject: [PATCH 13/13] Cambridge --- tests/fsharp/core/attributes/test.fsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fsharp/core/attributes/test.fsx b/tests/fsharp/core/attributes/test.fsx index f8f60ee019c..392cd6299fd 100644 --- a/tests/fsharp/core/attributes/test.fsx +++ b/tests/fsharp/core/attributes/test.fsx @@ -1136,7 +1136,7 @@ module Bug5762 = let moduleType = typeof.DeclaringType let mFindFirstFile = moduleType.GetMethod("FindFirstFile") let dataParam = mFindFirstFile.GetParameters().[1] - let marshalAsAttrs = dataParam.GetCustomAttributes(typeof, false) + let marshalAsAttrs = dataParam.GetCustomAttributes(typeof, false) |> Array.distinct check "gjhfdey547" (match marshalAsAttrs with | [| (:? MarshalAsAttribute as ma) |] when ma.Value = UnmanagedType.LPStruct -> true @@ -1145,7 +1145,7 @@ module Bug5762 = let findDataType = typeof check "dguyestgfuysdc" - (match findDataType.GetField("cFileName").GetCustomAttributes(typeof, false) with + (match findDataType.GetField("cFileName").GetCustomAttributes(typeof, false) |> Array.distinct with | [| (:? MarshalAsAttribute as ma) |] when ma.Value = UnmanagedType.ByValTStr && ma.SizeConst = 260 -> true