Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove multi-emit - internal restriction #14478

Merged
merged 15 commits into from
Jan 3, 2023
Merged
Binary file added a
Binary file not shown.
7 changes: 3 additions & 4 deletions src/Compiler/AbstractIL/ilsign.fs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,10 @@ 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 =
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/AbstractIL/ilsign.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ open System.IO
[<Sealed>]
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[]
Expand Down
46 changes: 28 additions & 18 deletions src/Compiler/Driver/CreateILModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ 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) =
Expand All @@ -91,14 +95,24 @@ 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)
Expand Down Expand Up @@ -127,15 +141,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
Expand Down
4 changes: 4 additions & 0 deletions src/Compiler/Driver/CreateILModule.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ open FSharp.Compiler.TypedTree
/// Represents the configuration settings used to perform strong-name signing
type StrongNameSigningInfo

/// Get the SigningInfo 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

Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Interactive/FSIstrings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +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)"
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 [<EntryPoint>] are not invoked in FSI. '%s' was not invoked. Execute '%s <args>' in order to invoke '%s' with the appropriate string array of command line arguments."
Loading