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

Deprecate --keycontainer #10999

Merged
merged 7 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 6 additions & 5 deletions src/fsharp/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,6 @@ let outputFileFlagsFsc (tcConfigB: TcConfigBuilder) =
OptionString (fun s -> tcConfigB.signer <- Some s), None,
Some (FSComp.SR.optsStrongKeyFile()))

CompilerOption
("keycontainer", tagString,
OptionString(fun s -> tcConfigB.container <- Some s), None,
Some(FSComp.SR.optsStrongKeyContainer()))

CompilerOption
("platform", tagString,
OptionString (fun s ->
Expand Down Expand Up @@ -1402,6 +1397,12 @@ let deprecatedFlagsFsc tcConfigB =
OptionUnit (fun () -> SetOptimizeOff tcConfigB),
Some(DeprecatedCommandLineOptionSuggestAlternative("-Ooff", "--optimize-", rangeCmdArgs)), None)


CompilerOption
("keycontainer", tagString,
OptionString(fun s -> tcConfigB.container <- Some s),
Some(DeprecatedCommandLineOptionSuggestAlternative("--keycontainer", "--keyfile", rangeCmdArgs)), None)

mlKeywordsFlag
gnuStyleErrorsFlag tcConfigB ]

Expand Down
16 changes: 9 additions & 7 deletions src/fsharp/CreateILModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let ValidateKeySigningAttributes (tcConfig : TcConfig, tcGlobals, topAttrs) =
let delaySignAttrib = AttributeHelpers.TryFindBoolAttribute tcGlobals "System.Reflection.AssemblyDelaySignAttribute" topAttrs.assemblyAttrs
let signerAttrib = AttributeHelpers.TryFindStringAttribute tcGlobals "System.Reflection.AssemblyKeyFileAttribute" topAttrs.assemblyAttrs
let containerAttrib = AttributeHelpers.TryFindStringAttribute tcGlobals "System.Reflection.AssemblyKeyNameAttribute" topAttrs.assemblyAttrs

// if delaySign is set via an attribute, validate that it wasn't set via an option
let delaysign =
match delaySignAttrib with
Expand All @@ -89,7 +89,7 @@ let ValidateKeySigningAttributes (tcConfig : TcConfig, tcGlobals, topAttrs) =
else
delaysign
| _ -> tcConfig.delaysign

// if signer is set via an attribute, validate that it wasn't set via an option
let signer =
match signerAttrib with
Expand All @@ -100,20 +100,22 @@ let ValidateKeySigningAttributes (tcConfig : TcConfig, tcGlobals, topAttrs) =
else
Some signer
| None -> tcConfig.signer

// 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)
// REVIEW: This is C# behavior, but it seems kind of sketchy that we fail silently
let container =
match containerAttrib with
| Some container ->
match containerAttrib with
| Some container ->
if not (FSharpEnvironment.isRunningOnCoreClr) then
warning(Error(FSComp.SR.containerDeprecated(), rangeCmdArgs))
if tcConfig.container.IsSome && tcConfig.container <> Some container then
warning(Error(FSComp.SR.fscKeyNameWarning(), rangeCmdArgs))
warning(Error(FSComp.SR.fscKeyNameWarning(), rangeCmdArgs))
tcConfig.container
else
Some container
| None -> tcConfig.container

StrongNameSigningInfo (delaysign, tcConfig.publicsign, signer, container)

/// Get the object used to perform strong-name signing
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1553,3 +1553,4 @@ forFormatInvalidForInterpolated4,"Interpolated strings used as type IFormattable
3390,xmlDocUnresolvedCrossReference,"This XML comment is invalid: unresolved cross-reference '%s'"
3390,xmlDocMissingParameter,"This XML comment is incomplete: no documentation for parameter '%s'"
3391,tcLiteralAttributeCannotUseActivePattern,"A [<Literal>] declaration cannot use an active pattern for its identifier"
3392,containerDeprecated,"The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead."
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Funkce {0} vyžaduje knihovnu F# pro verzi jazyka {1} nebo novější.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Dostupná přetížení:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Für das Feature "{0}" ist die F#-Bibliothek für die Sprachversion {1} oder höher erforderlich.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Verfügbare Überladungen:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">La característica "{0}" requiere la biblioteca de F# para la versión de lenguaje {1} o superior.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Sobrecargas disponibles:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">La fonctionnalité '{0}' nécessite la bibliothèque F# pour le langage version {1} ou ultérieure.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Surcharges disponibles :\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Con la funzionalità '{0}' è richiesta la libreria F# per la versione {1} o successiva del linguaggio.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Overload disponibili:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">機能 '{0}' を使用するには、言語バージョン {1} 以上の F# ライブラリが必要です。</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">使用可能なオーバーロード:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">언어 버전 {1} 이상에서 '{0}' 기능을 사용하려면 F# 라이브러리가 필요합니다.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">사용 가능한 오버로드:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Funkcja „{0}” wymaga biblioteki języka F# dla wersji językowej {1} lub nowszej.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Dostępne przeciążenia:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">O recurso '{0}' exige a biblioteca F# para a versão da linguagem {1} ou posterior.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Sobrecargas disponíveis:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Компоненту "{0}" требуется библиотека F# для языка версии {1} или более поздней.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Доступные перегрузки:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">'{0}' özelliği için F# kitaplığının {1} veya üstü dil sürümü gerekir.</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">Kullanılabilir aşırı yüklemeler:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">功能“{0}”需要 {1} 或更高语言版本的 F# 库。</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">可用重载:\n{0}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/fsharp/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">功能 '{0}' 需要語言版本 {1} 或更高的 F# 程式庫。</target>
<note />
</trans-unit>
<trans-unit id="containerDeprecated">
<source>The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</source>
<target state="new">The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.</target>
<note />
</trans-unit>
<trans-unit id="csAvailableOverloads">
<source>Available overloads:\n{0}</source>
<target state="translated">可用的多載:\n{0}</target>
Expand Down
50 changes: 50 additions & 0 deletions tests/FSharp.Compiler.UnitTests/AssemblySigningAttributes.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test.Utilities.Compiler
open FSharp.Test.Utilities.Xunit.Attributes
open FSharp.Test.Utilities

module AssemblySigning =

#if !NETCOREAPP
[<Fact>]
#endif
let ``--keycontainer:foo`` () =
FSharp """
module SignMe

open System
open System.Reflection

"""
|> withOptions ["--keycontainer:myContainer"]
|> compile
|> shouldFail
|> withWarningCode 0075
|> withDiagnosticMessageMatches "The command-line option '--keycontainer' has been deprecated. Use '--keyfile' instead."
|> ignore


//Expects: warning FS3392: The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead.
#if !NETCOREAPP
[<Fact>]
#endif
let AssemblyKeyNameAttribute () =
FSharp """
module SignMe

open System
open System.Reflection

[<assembly:AssemblyKeyNameAttribute("myContainer")>]
do ()
"""
|> asFs
|> compile
|> shouldFail
|> withWarningCode 3392
|> withDiagnosticMessageMatches "The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead."
|> ignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Compile Include="ByteMemoryTests.fs" />
<Compile Include="FsiTests.fs" />
<Compile Include="ByteMemoryTests.fs" />
<Compile Include="AssemblySigningAttributes.fs" />
<Compile Include="..\..\tests\service\FsUnit.fs">
<Link>CompilerService\FsUnit.fs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Copyright (c) Microsoft Corporation. All Rights Reserved.
--doc:<file> Write the xmldoc of the assembly to
the given file
--keyfile:<file> Specify a strong name key file
--keycontainer:<string> Specify a strong name key container
--platform:<string> Limit which platforms this code can
run on: x86, Itanium, x64,
anycpu32bitpreferred, or anycpu. The
Expand Down