diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
index b4df947561a..c7f68777166 100644
--- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
+++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
@@ -6,6 +6,7 @@
* Fix parsing errors using anonymous records and units of measures ([PR #18543](https://github.com/dotnet/fsharp/pull/18543))
* Fix parsing errors using anonymous records and code quotations ([PR #18603](https://github.com/dotnet/fsharp/pull/18603))
+* Better error message for attribute targets. ([PR #18641](https://github.com/dotnet/fsharp/pull/18641))
* Fixed: Allow `return`, `return!`, `yield`, `yield!` type annotations without parentheses ([PR #18533](https://github.com/dotnet/fsharp/pull/18533))
* Allow `let!` and `use!` type annotations without requiring parentheses ([PR #18508](https://github.com/dotnet/fsharp/pull/18508))
* Fix find all references for F# exceptions ([PR #18565](https://github.com/dotnet/fsharp/pull/18565))
diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs
index 0270de6b14c..5862b907e05 100644
--- a/src/Compiler/Checking/Expressions/CheckExpressions.fs
+++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs
@@ -143,6 +143,8 @@ exception StandardOperatorRedefinitionWarning of string * range
exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option
+exception InvalidAttributeTargetForLanguageElement of elementTargets: string array * allowedTargets: string array * range: range
+
//----------------------------------------------------------------------------------------------
// Helpers for determining if/what specifiers a string has.
// Used to decide if interpolated string can be lowered to a concat call.
@@ -11356,7 +11358,29 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt
if (directedTargets = AttributeTargets.Assembly || directedTargets = AttributeTargets.Module) then
errorR(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElementUseDo(), mAttr))
else
- warning(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElement(), mAttr))
+ let attributeTargetsToString (targets: int) =
+ [|
+ if targets &&& int AttributeTargets.Assembly <> 0 then "assembly"
+ if targets &&& int AttributeTargets.Module <> 0 then "module"
+ if targets &&& int AttributeTargets.Class <> 0 then "class"
+ if targets &&& int AttributeTargets.Struct <> 0 then "struct"
+ if targets &&& int AttributeTargets.Enum <> 0 then "enum"
+ if targets &&& int AttributeTargets.Constructor <> 0 then "constructor"
+ if targets &&& int AttributeTargets.Method <> 0 then "method"
+ if targets &&& int AttributeTargets.Property <> 0 then "property"
+ if targets &&& int AttributeTargets.Field <> 0 then "field"
+ if targets &&& int AttributeTargets.Event <> 0 then "event"
+ if targets &&& int AttributeTargets.Interface <> 0 then "interface"
+ if targets &&& int AttributeTargets.Parameter <> 0 then "parameter"
+ if targets &&& int AttributeTargets.Delegate <> 0 then "delegate"
+ if targets &&& int AttributeTargets.ReturnValue <> 0 then "return value"
+ if targets &&& int AttributeTargets.GenericParameter <> 0 then "type parameter"
+ |]
+
+ let elementTargets = attributeTargetsToString (int attrTgt)
+ let allowedTargets = attributeTargetsToString validOn
+
+ warning(InvalidAttributeTargetForLanguageElement(elementTargets, allowedTargets, mAttr))
constrainedTargets
diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi
index 5992a4afc95..9e3014896c8 100644
--- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi
+++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi
@@ -121,6 +121,11 @@ exception StandardOperatorRedefinitionWarning of string * range
exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option
+exception InvalidAttributeTargetForLanguageElement of
+ elementTargets: string array *
+ allowedTargets: string array *
+ range: range
+
val TcFieldInit: range -> ILFieldInit -> Const
/// Indicates whether a syntactic type is allowed to include new type variables
diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs
index 1845c2e00a6..da7d3622a51 100644
--- a/src/Compiler/Driver/CompilerDiagnostics.fs
+++ b/src/Compiler/Driver/CompilerDiagnostics.fs
@@ -155,6 +155,7 @@ type Exception with
| LibraryUseOnly m
| FieldsFromDifferentTypes(_, _, _, m)
| IndeterminateType m
+ | InvalidAttributeTargetForLanguageElement(_, _, m)
| TyconBadArgs(_, _, _, m) -> Some m
| FieldNotContained(_, _, _, _, _, arf, _, _) -> Some arf.Range
@@ -353,6 +354,7 @@ type Exception with
| ConstraintSolverNullnessWarningWithTypes _ -> 3261
| ConstraintSolverNullnessWarningWithType _ -> 3261
| ConstraintSolverNullnessWarning _ -> 3261
+ | InvalidAttributeTargetForLanguageElement _ -> 842
| _ -> 193
type PhasedDiagnostic with
@@ -611,6 +613,9 @@ module OldStyleMessages =
let DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE () =
Message("DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer", "%s%s%s%s")
+ let InvalidAttributeTargetForLanguageElement1E () = Message("InvalidAttributeTargetForLanguageElement1", "%s%s")
+ let InvalidAttributeTargetForLanguageElement2E () = Message("InvalidAttributeTargetForLanguageElement2", "")
+
#if DEBUG
let mutable showParserStackOnParseError = false
#endif
@@ -1932,6 +1937,14 @@ type Exception with
s2
)
+ | InvalidAttributeTargetForLanguageElement(elementTargets, allowedTargets, _m) ->
+ if Array.isEmpty elementTargets then
+ os.AppendString(InvalidAttributeTargetForLanguageElement2E().Format)
+ else
+ let elementTargets = String.concat ", " elementTargets
+ let allowedTargets = allowedTargets |> String.concat ", "
+ os.AppendString(InvalidAttributeTargetForLanguageElement1E().Format elementTargets allowedTargets)
+
// Strip TargetInvocationException wrappers
| :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).Output(os, suggestNames)
diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt
index 78dde5bd148..f259f06cac0 100644
--- a/src/Compiler/FSComp.txt
+++ b/src/Compiler/FSComp.txt
@@ -698,7 +698,6 @@ tcUnnamedArgumentsDoNotFormPrefix,"The unnamed arguments do not form a prefix of
839,tcUnexpectedConditionInImportedAssembly,"Unexpected condition in imported assembly: failed to decode AttributeUsage attribute"
840,tcUnrecognizedAttributeTarget,"Unrecognized attribute target. Valid attribute targets are 'assembly', 'module', 'type', 'method', 'property', 'return', 'param', 'field', 'event', 'constructor'."
841,tcAttributeIsNotValidForLanguageElementUseDo,"This attribute is not valid for use on this language element. Assembly attributes should be attached to a 'do ()' declaration, if necessary within an F# module."
-842,tcAttributeIsNotValidForLanguageElement,"This attribute is not valid for use on this language element"
843,tcOptionalArgumentsCannotBeUsedInCustomAttribute,"Optional arguments cannot be used in custom attributes"
844,tcPropertyCannotBeSet0,"This property cannot be set"
845,tcPropertyOrFieldNotFoundInAttribute,"This property or field was not found on this custom attribute type"
diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx
index 1b8be22d319..7ba844291c9 100644
--- a/src/Compiler/FSStrings.resx
+++ b/src/Compiler/FSStrings.resx
@@ -1146,4 +1146,10 @@
keyword 'while!'
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+ This attribute is not valid for use on this language element
+
\ No newline at end of file
diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf
index 022d1082ac2..bb56261f125 100644
--- a/src/Compiler/xlf/FSComp.txt.cs.xlf
+++ b/src/Compiler/xlf/FSComp.txt.cs.xlf
@@ -5142,11 +5142,6 @@
Tento atribut není platný pro použití u tohoto elementu jazyka. Atributy sestavení by měly být připojené k deklaraci do (), v případě potřeby v modulu F#.
-
- This attribute is not valid for use on this language element
- Tento atribut není platný pro použití u tohoto elementu jazyka.
-
- Optional arguments cannot be used in custom attributesNepovinné argumenty se u vlastních atributů použít nedají.
diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf
index a31c82200b8..7b8d6567c1c 100644
--- a/src/Compiler/xlf/FSComp.txt.de.xlf
+++ b/src/Compiler/xlf/FSComp.txt.de.xlf
@@ -5142,11 +5142,6 @@
Dieses Attribut ist für dieses Sprachelement nicht gültig. Assemblyattribute sollten an eine "do ()"-Deklaration angefügt werden, falls notwendig innerhalb eines F#-Moduls.
-
- This attribute is not valid for use on this language element
- Dieses Attribut ist für dieses Sprachelement nicht gültig.
-
- Optional arguments cannot be used in custom attributesOptionale Argumente dürfen nicht für benutzerdefinierte Attribute verwendet werden.
diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf
index 66a3c4aebce..8a0ac83a342 100644
--- a/src/Compiler/xlf/FSComp.txt.es.xlf
+++ b/src/Compiler/xlf/FSComp.txt.es.xlf
@@ -5142,11 +5142,6 @@
Este atributo no es válido para usarlo en este elemento de lenguaje. Los atributos de ensamblado deben asociarse a una declaración 'do ()', si es necesario en un módulo de F#.
-
- This attribute is not valid for use on this language element
- Este atributo no es válido para usarlo en este elemento de lenguaje.
-
- Optional arguments cannot be used in custom attributesNo se pueden usar argumentos opcionales en atributos personalizados.
diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf
index 62379251f1d..621813988a3 100644
--- a/src/Compiler/xlf/FSComp.txt.fr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.fr.xlf
@@ -5142,11 +5142,6 @@
L'utilisation de cet attribut n'est pas valide sur cet élément de langage. Les attributs d'assembly doivent être attachés à une déclaration 'do ()', si nécessaire, dans un module F#.
-
- This attribute is not valid for use on this language element
- L'utilisation de cet attribut n'est pas valide sur cet élément de langage
-
- Optional arguments cannot be used in custom attributesImpossible d'utiliser les arguments facultatifs dans les attributs personnalisés
diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf
index cf787797a33..76294e7ac7f 100644
--- a/src/Compiler/xlf/FSComp.txt.it.xlf
+++ b/src/Compiler/xlf/FSComp.txt.it.xlf
@@ -5142,11 +5142,6 @@
Attributo non valido per l'utilizzo in questo elemento del linguaggio. Gli attributi degli assembly devono essere collegati a una dichiarazione 'do ()', se necessario all'interno di un modulo F#.
-
- This attribute is not valid for use on this language element
- Attributo non valido per l'utilizzo in questo elemento del linguaggio
-
- Optional arguments cannot be used in custom attributesNon è possibile usare argomenti facoltativi in attributi personalizzati
diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf
index 4dbdcf3448c..cf31f12757e 100644
--- a/src/Compiler/xlf/FSComp.txt.ja.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ja.xlf
@@ -5142,11 +5142,6 @@
この言語要素では、この属性を使用できません。アセンブリの属性は (必要に応じて F# モジュール内で) 'do ()' 宣言にアタッチする必要があります。
-
- This attribute is not valid for use on this language element
- この言語要素では、この属性を使用できません
-
- Optional arguments cannot be used in custom attributesカスタム属性にはオプションの引数を使用できません
diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf
index 2ff64434e9f..70f312b88cd 100644
--- a/src/Compiler/xlf/FSComp.txt.ko.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ko.xlf
@@ -5142,11 +5142,6 @@
이 특성은 이 언어 요소에 사용할 수 없습니다. 어셈블리 특성은 필요한 경우 F# 모듈 내에서 'do ()' 선언에 연결해야 합니다.
-
- This attribute is not valid for use on this language element
- 이 특성은 이 언어 요소에 사용할 수 없습니다.
-
- Optional arguments cannot be used in custom attributes선택적 인수는 사용자 지정 특성에 사용할 수 없습니다.
diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf
index 20af7d96049..5cb379287e1 100644
--- a/src/Compiler/xlf/FSComp.txt.pl.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pl.xlf
@@ -5142,11 +5142,6 @@
Ten atrybut jest nieprawidłowy do użycia w tym elemencie języka. Atrybuty zestawu powinny być dołączone do deklaracji „do ()” (w module języka F#, jeśli to konieczne).
-
- This attribute is not valid for use on this language element
- Ten atrybut jest nieprawidłowy do użycia w tym elemencie języka
-
- Optional arguments cannot be used in custom attributesArgumenty opcjonalne nie mogą być używane w atrybutach niestandardowych
diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
index e891cd02465..8f67095285e 100644
--- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
@@ -5142,11 +5142,6 @@
Este atributo não é válido para ser usado neste elemento de linguagem. Os atributos de assembly devem ser anexados a uma declaração 'do ()' e, se necessário, em um módulo F#.
-
- This attribute is not valid for use on this language element
- Este atributo não é válido para ser usado neste elemento de linguagem
-
- Optional arguments cannot be used in custom attributesArgumentos opcionais não podem ser usados em atributos personalizados
diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf
index 0bc6074f622..19de2b0d1a9 100644
--- a/src/Compiler/xlf/FSComp.txt.ru.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ru.xlf
@@ -5142,11 +5142,6 @@
Не допускается использование этого атрибута для этого элемента языка. Атрибуты сборки необходимо присоединять к объявлению "do ()" (при необходимости внутри модуля F#).
-
- This attribute is not valid for use on this language element
- Не допускается использование этого атрибута для этого элемента языка
-
- Optional arguments cannot be used in custom attributesНеобязательные аргументы не могут использоваться в пользовательских атрибутах
diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf
index dcbdbafb5e2..eb357aaa843 100644
--- a/src/Compiler/xlf/FSComp.txt.tr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.tr.xlf
@@ -5142,11 +5142,6 @@
Bu öznitelik, bu dil öğesinde kullanılmak için geçerli değil. Bütünleştirilmiş kod öznitelikleri, bir 'do ()' bildirimine, gerekirse F# modülü içine iliştirilmelidir.
-
- This attribute is not valid for use on this language element
- Bu öznitelik, bu dil öğesinde kullanılmak için geçerli değil
-
- Optional arguments cannot be used in custom attributesİsteğe bağlı bağımsız değişkenler özel özniteliklerde kullanılamaz
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
index 34c4cc88dab..256302b235e 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
@@ -5142,11 +5142,6 @@
对此语言元素使用此特性无效。如有需要,应将程序集特性附加到 F# 模块中的“do ()”声明。
-
- This attribute is not valid for use on this language element
- 对此语言元素使用此特性无效
-
- Optional arguments cannot be used in custom attributes自定义特性中不能使用可选参数
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
index 628729a3fe2..674e3ee9c45 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
@@ -5142,11 +5142,6 @@
這個屬性不能用在這個語言項目上。組件屬性應該附加到 'do ()' 宣告 (如果 F# 模組中需要的話)。
-
- This attribute is not valid for use on this language element
- 這個屬性不能用在這個語言項目上
-
- Optional arguments cannot be used in custom attributes選擇性的引數不能用在自訂屬性中
diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf
index b7040399218..62c8a4c9b5b 100644
--- a/src/Compiler/xlf/FSStrings.cs.xlf
+++ b/src/Compiler/xlf/FSStrings.cs.xlf
@@ -57,6 +57,16 @@
Nejméně jedna informační zpráva v načteném souboru\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributePřípady sjednocení s malými písmeny jsou povolené jenom při použití atributu RequireQualifiedAccess.
diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf
index f7efcf4dcea..bd7231f7eb0 100644
--- a/src/Compiler/xlf/FSStrings.de.xlf
+++ b/src/Compiler/xlf/FSStrings.de.xlf
@@ -57,6 +57,16 @@
Mindestens eine Informationsmeldung in der geladenen Datei.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeDiskriminierte Union-Fälle in Kleinbuchstaben sind nur zulässig, wenn das RequireQualifiedAccess-Attribut verwendet wird.
diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf
index 4fbafe2a151..b742c23b61a 100644
--- a/src/Compiler/xlf/FSStrings.es.xlf
+++ b/src/Compiler/xlf/FSStrings.es.xlf
@@ -57,6 +57,16 @@
Uno o más mensajes informativos en el archivo cargado.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeLos casos de unión discriminada en minúsculas solo se permiten cuando se usa el atributo RequireQualifiedAccess
diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf
index e1e1e1fad09..5ea093f08b6 100644
--- a/src/Compiler/xlf/FSStrings.fr.xlf
+++ b/src/Compiler/xlf/FSStrings.fr.xlf
@@ -57,6 +57,16 @@
Un ou plusieurs messages d’information dans le fichier chargé.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeLes cas d’union discriminée en minuscules sont uniquement autorisés lors de l’utilisation de l’attribut RequireQualifiedAccess.
diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf
index 5f9b2560737..cc5b2dee04d 100644
--- a/src/Compiler/xlf/FSStrings.it.xlf
+++ b/src/Compiler/xlf/FSStrings.it.xlf
@@ -57,6 +57,16 @@
Uno o più messaggi informativi nel file caricato.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeI casi di unione discriminati minuscoli sono consentiti solo quando si usa l'attributo RequireQualifiedAccess
diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf
index b18b3c851a4..8ff3956536f 100644
--- a/src/Compiler/xlf/FSStrings.ja.xlf
+++ b/src/Compiler/xlf/FSStrings.ja.xlf
@@ -57,6 +57,16 @@
読み込まれたファイル内の 1 つ以上の情報メッセージ。\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute小文字で区別される和集合のケースは、RequireQualifiedAccess 属性を使用する場合にのみ許可されます
diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf
index 5de9d0525e3..e7811efd1fb 100644
--- a/src/Compiler/xlf/FSStrings.ko.xlf
+++ b/src/Compiler/xlf/FSStrings.ko.xlf
@@ -57,6 +57,16 @@
로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute소문자로 구분된 공용 구조체 케이스는 RequireQualifiedAccess 특성을 사용하는 경우에만 허용됩니다.
diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf
index 4433284fb84..7d10392f2d0 100644
--- a/src/Compiler/xlf/FSStrings.pl.xlf
+++ b/src/Compiler/xlf/FSStrings.pl.xlf
@@ -57,6 +57,16 @@
Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributePrzypadki unii z dyskryminatorem z małymi literami są dozwolone tylko w przypadku używania atrybutu RequireQualifiedAccess
diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf
index bce9c0c6fdb..b8f1477ffd8 100644
--- a/src/Compiler/xlf/FSStrings.pt-BR.xlf
+++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf
@@ -57,6 +57,16 @@
Uma ou mais mensagens informativas no arquivo carregado.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeOs casos de união discriminados em letras minúsculas só são permitidos ao usar o atributo RequireQualifiedAccess
diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf
index 53877846345..cf4ea76ede9 100644
--- a/src/Compiler/xlf/FSStrings.ru.xlf
+++ b/src/Compiler/xlf/FSStrings.ru.xlf
@@ -57,6 +57,16 @@
Одно или несколько информационных сообщений в загруженном файле.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeРазмеченные в нижнем регистре случаи объединения разрешены только при использовании атрибута RequireQualifiedAccess
diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf
index 3c9b2f92ab5..a4812ae8b03 100644
--- a/src/Compiler/xlf/FSStrings.tr.xlf
+++ b/src/Compiler/xlf/FSStrings.tr.xlf
@@ -57,6 +57,16 @@
Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attributeKüçük harf ayrımlı birleşim durumlarına yalnızca RequireQualifiedAccess özniteliği kullanılırken izin verilir
diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf
index 0b5a33c7d39..6f9680c914f 100644
--- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf
+++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf
@@ -57,6 +57,16 @@
加载文件 .\n 中有一条或多条信息性消息
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute仅当使用 RequireQualifiedAccess 属性时才允许区分小写的联合事例
diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf
index 7d53a56040a..581e38ca65e 100644
--- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf
+++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf
@@ -57,6 +57,16 @@
已載入檔案中的一或多個資訊訊息。\n
+
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+ This attribute cannot be applied to {0}. Valid targets are: {1}
+
+
+
+ This attribute is not valid for use on this language element
+ This attribute is not valid for use on this language element
+
+ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute只有在使用 RequireQualifiedAccess 屬性時,才允許小寫區分聯結案例
diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs
index 70d72f94855..c2246d10722 100644
--- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs
+++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs
@@ -112,10 +112,13 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute is not valid for use on this language element")
- (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute is not valid for use on this language element")
- (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to property, field. Valid targets are: method");
+ (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to field. Valid targets are: method");
+ (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to property, field. Valid targets are: method");
+ (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to field. Valid targets are: method");
+ (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to property, event, return value. Valid targets are: method");
+ (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to property. Valid targets are: method");
+ (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
]
// SOURCE=E_AttributeTargets02.fs # E_AttributeTargets02.fs
@@ -125,17 +128,17 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute is not valid for use on this language element")
- (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute is not valid for use on this language element")
- (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute is not valid for use on this language element")
- (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.")
+ (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute cannot be applied to field. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate");
+ (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute cannot be applied to property, event, return value. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate");
+ (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute cannot be applied to method, event, return value. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate");
+ (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.")
]
// SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs
[]
- let ``E_AttributeTargetIsField01_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsField01_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldSucceed
@@ -148,30 +151,30 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 9, Col 3, Line 9, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 12, Col 3, Line 12, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 15, Col 3, Line 15, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 18, Col 3, Line 18, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 21, Col 3, Line 21, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 24, Col 3, Line 24, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 27, Col 3, Line 27, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 30, Col 3, Line 30, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 33, Col 3, Line 33, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 36, Col 3, Line 36, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 39, Col 3, Line 39, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 42, Col 3, Line 42, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 45, Col 3, Line 45, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 49, Col 3, Line 49, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 56, Col 3, Line 56, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 64, Col 3, Line 64, Col 12, "This attribute is not valid for use on this language element")
- (Warning 842, Line 66, Col 7, Line 66, Col 16, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 9, Col 3, Line 9, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 12, Col 3, Line 12, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 15, Col 3, Line 15, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 18, Col 3, Line 18, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 21, Col 3, Line 21, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 24, Col 3, Line 24, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 27, Col 3, Line 27, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 30, Col 3, Line 30, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 33, Col 3, Line 33, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 36, Col 3, Line 36, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 39, Col 3, Line 39, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 42, Col 3, Line 42, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 45, Col 3, Line 45, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 49, Col 3, Line 49, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 56, Col 3, Line 56, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 64, Col 3, Line 64, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field")
+ (Warning 842, Line 66, Col 7, Line 66, Col 16, "This attribute cannot be applied to method, return value. Valid targets are: field")
]
// SOURCE=E_AttributeTargetIsField02.fs # E_AttributeTargetIsField02.fs
[]
- let ``E_AttributeTargetIsField02_fs 8.0`` compilation =
+ let ``E_AttributeTargetIsField02_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldSucceed
@@ -186,9 +189,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsMethod02.fs # E_AttributeTargetIsMethod02.fs
[]
- let ``E_AttributeTargetIsMethod02_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsMethod02_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldSucceed
@@ -201,24 +204,24 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 12, Col 3, Line 12, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 15, Col 3, Line 15, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 18, Col 3, Line 18, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 21, Col 3, Line 21, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 24, Col 3, Line 24, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 26, Col 7, Line 26, Col 17, "This attribute is not valid for use on this language element")
- (Warning 842, Line 28, Col 3, Line 28, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 31, Col 3, Line 31, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 34, Col 3, Line 34, Col 13, "This attribute is not valid for use on this language element")
- (Warning 842, Line 39, Col 3, Line 39, Col 13, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 12, Col 3, Line 12, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 15, Col 3, Line 15, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 18, Col 3, Line 18, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 21, Col 3, Line 21, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 24, Col 3, Line 24, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 26, Col 7, Line 26, Col 17, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 28, Col 3, Line 28, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 31, Col 3, Line 31, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 34, Col 3, Line 34, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 39, Col 3, Line 39, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
]
// SOURCE=E_AttributeTargetIsMethod03.fs # E_AttributeTargetIsMethod03.fs
[]
- let ``E_AttributeTargetIsMethod03_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsMethod03_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldSucceed
@@ -231,21 +234,21 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 12, Col 6, Line 12, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 15, Col 6, Line 15, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 18, Col 6, Line 18, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 20, Col 10, Line 20, Col 20, "This attribute is not valid for use on this language element")
- (Warning 842, Line 22, Col 6, Line 22, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 25, Col 6, Line 25, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 28, Col 6, Line 28, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 31, Col 6, Line 31, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 34, Col 6, Line 34, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 37, Col 6, Line 37, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 39, Col 10, Line 39, Col 20, "This attribute is not valid for use on this language element")
- (Warning 842, Line 41, Col 6, Line 41, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 44, Col 6, Line 44, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 47, Col 6, Line 47, Col 16, "This attribute is not valid for use on this language element")
- (Warning 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 12, Col 6, Line 12, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 15, Col 6, Line 15, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 18, Col 6, Line 18, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 20, Col 10, Line 20, Col 20, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 22, Col 6, Line 22, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 25, Col 6, Line 25, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 28, Col 6, Line 28, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 31, Col 6, Line 31, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 34, Col 6, Line 34, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 37, Col 6, Line 37, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 39, Col 10, Line 39, Col 20, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 41, Col 6, Line 41, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 44, Col 6, Line 44, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 47, Col 6, Line 47, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
+ (Warning 842, Line 52, Col 6, Line 52, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
]
// SOURCE=E_AttributeTargetIsMethod04.fs # E_AttributeTargetIsMethod04.fs
@@ -256,8 +259,10 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method")
+ (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class. Valid targets are: method")
+ (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method")
+ (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to struct. Valid targets are: method")
]
// SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs
@@ -299,14 +304,15 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute cannot be applied to method, property, field, return value. Valid targets are: assembly, class")
+ (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute cannot be applied to property, field, return value. Valid targets are: assembly, class")
]
// SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs
[]
- let ``AttributeTargetIsStruct_fs 8.0`` compilation =
+ let ``AttributeTargetIsStruct_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -319,9 +325,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=AttributeTargetIsClass.fs # AttributeTargetIsClass.fs
[]
- let ``AttributeTargetIsClass_fs 8.0`` compilation =
+ let ``AttributeTargetIsClass_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -334,9 +340,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsStruct.fs # E_AttributeTargetIsStruct.fs
[]
- let ``E_AttributeTargetIsStruct_fs 8.0`` compilation =
+ let ``E_AttributeTargetIsStruct_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -347,25 +353,25 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 13, Col 3, Line 13, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 22, Col 11, Line 22, Col 22, "This attribute is not valid for use on this language element")
- (Warning 842, Line 25, Col 3, Line 25, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 34, Col 3, Line 34, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 35, Col 3, Line 35, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 40, Col 3, Line 40, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 41, Col 3, Line 41, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 49, Col 3, Line 49, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 50, Col 3, Line 50, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 53, Col 3, Line 53, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 54, Col 3, Line 54, Col 18, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 13, Col 3, Line 13, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 22, Col 11, Line 22, Col 22, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 25, Col 3, Line 25, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 34, Col 3, Line 34, Col 18, "This attribute cannot be applied to class. Valid targets are: interface")
+ (Warning 842, Line 35, Col 3, Line 35, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 40, Col 3, Line 40, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 41, Col 3, Line 41, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
+ (Warning 842, Line 49, Col 3, Line 49, Col 18, "This attribute cannot be applied to class. Valid targets are: interface")
+ (Warning 842, Line 50, Col 3, Line 50, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 53, Col 3, Line 53, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 54, Col 3, Line 54, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
]
// SOURCE=E_AttributeTargetIsClass.fs # E_AttributeTargetIsClass.fs
[]
- let ``E_AttributeTargetIsClass_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsClass_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -376,16 +382,16 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 22, Col 10, Line 22, Col 22, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 22, Col 10, Line 22, Col 22, "This attribute cannot be applied to class. Valid targets are: struct")
]
// SOURCE=E_AttributeTargetIsClass01.fs # E_AttributeTargetIsClass01.fs
[]
- let ``E_AttributeTargetIsClass01_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsClass01_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -396,8 +402,8 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 7, Col 3, Line 7, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 10, Col 10, Line 10, Col 25, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 7, Col 3, Line 7, Col 18, "This attribute cannot be applied to class. Valid targets are: interface");
+ (Warning 842, Line 10, Col 10, Line 10, Col 25, "This attribute cannot be applied to class. Valid targets are: interface")
]
// SOURCE=MarshalAsAttribute.fs # MarshalAsAttribute.fs
@@ -477,13 +483,13 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs
[]
- let ``E_AttributeTargetIsField03_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsField03_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field")
]
// SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs
@@ -495,7 +501,7 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field")
]
// SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs
@@ -505,7 +511,7 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field")
]
// SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs
@@ -516,16 +522,16 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element");
- (Warning 3878, Line 14, Col 18, Line 14, Col 23, "This attribute is not valid for use on union cases with fields.");
+ (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field")
+ (Warning 3878, Line 14, Col 18, Line 14, Col 23, "This attribute is not valid for use on union cases with fields.")
(Warning 3878, Line 15, Col 28, Line 15, Col 33, "This attribute is not valid for use on union cases with fields.")
]
// SOURCE=E_AttributeTargetIsProperty01.fs # E_AttributeTargetIsField03.fs
[]
- let ``E_AttributeTargetIsProperty01_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsProperty01_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -538,9 +544,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsCtor01.fs # E_AttributeTargetIsCtor01.fs
[]
- let ``E_AttributeTargetIsCtor01_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsCtor01_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -551,17 +557,17 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 9, Col 15, Line 9, Col 27, "This attribute is not valid for use on this language element")
- (Warning 842, Line 11, Col 16, Line 11, Col 28, "This attribute is not valid for use on this language element")
- (Warning 842, Line 14, Col 15, Line 14, Col 27, "This attribute is not valid for use on this language element")
- (Warning 842, Line 17, Col 16, Line 17, Col 28, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 9, Col 15, Line 9, Col 27, "This attribute cannot be applied to constructor. Valid targets are: method")
+ (Warning 842, Line 11, Col 16, Line 11, Col 28, "This attribute cannot be applied to constructor. Valid targets are: method")
+ (Warning 842, Line 14, Col 15, Line 14, Col 27, "This attribute cannot be applied to constructor. Valid targets are: method")
+ (Warning 842, Line 17, Col 16, Line 17, Col 28, "This attribute cannot be applied to constructor. Valid targets are: method")
]
// SOURCE=AttributeTargetsIsEnum01.fs # AttributeTargetsIsEnum01.fs
[]
- let ``AttributeTargetsIsEnum01_fs 8.0`` compilation =
+ let ``AttributeTargetsIsEnum01_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -574,9 +580,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsEnum01.fs # E_AttributeTargetIsEnum01.fs
[]
- let ``E_AttributeTargetIsEnum01_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsEnum01_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -587,17 +593,17 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 22, Col 3, Line 22, Col 17, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to enum. Valid targets are: struct")
+ (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute cannot be applied to enum. Valid targets are: class")
+ (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to enum. Valid targets are: interface")
+ (Warning 842, Line 22, Col 3, Line 22, Col 17, "This attribute cannot be applied to enum. Valid targets are: delegate")
]
// SOURCE=AttributeTargetsIsDelegate01.fs # AttributeTargetsIsDelegate01.fs
[]
- let ``AttributeTargetsIsDelegate01_fs 8.0`` compilation =
+ let ``AttributeTargetsIsDelegate01_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -610,9 +616,9 @@ module CustomAttributes_AttributeUsage =
// SOURCE=E_AttributeTargetIsDelegate01.fs # E_AttributeTargetIsDelegate01.fs
[]
- let ``E_AttributeTargetIsDelegate01_fs 8.0`` compilation =
+ let ``E_AttributeTargetIsDelegate01_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -623,10 +629,10 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 20, Col 3, Line 20, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 22, Col 3, Line 22, Col 13, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute cannot be applied to delegate. Valid targets are: class")
+ (Warning 842, Line 20, Col 3, Line 20, Col 15, "This attribute cannot be applied to delegate. Valid targets are: struct")
+ (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to delegate. Valid targets are: interface")
+ (Warning 842, Line 22, Col 3, Line 22, Col 13, "This attribute cannot be applied to delegate. Valid targets are: enum")
]
[]
@@ -642,9 +648,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
// SOURCE=AttributeTargetsIsInterface.fs # AttributeTargetsIsInterface.fs
[]
- let ``AttributeTargetsIsInterface_fs 8.0`` compilation =
+ let ``AttributeTargetsIsInterface_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -658,9 +664,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
// SOURCE=E_AttributeTargetIsInterface.fs # E_AttributeTargetIsInterface.fs
[]
- let ``E_AttributeTargetIsInterface_fs 8_0`` compilation =
+ let ``E_AttributeTargetIsInterface_fs 9_0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -671,17 +677,17 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 11, Col 3, Line 11, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 14, Col 3, Line 14, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 18, Col 3, Line 18, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 11, Col 3, Line 11, Col 14, "This attribute cannot be applied to interface. Valid targets are: class")
+ (Warning 842, Line 14, Col 3, Line 14, Col 15, "This attribute cannot be applied to interface. Valid targets are: struct")
+ (Warning 842, Line 18, Col 3, Line 18, Col 14, "This attribute cannot be applied to interface. Valid targets are: class")
+ (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to interface. Valid targets are: struct")
]
// SOURCE= E_AttributeTargetIsClass02.fs # E_AttributeTargetIsClass02.fs
[]
- let ``E_AttributeTargetIsClass02_fs 8.0`` compilation =
+ let ``E_AttributeTargetIsClass02_fs 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldSucceed
@@ -692,18 +698,18 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 15, Col 3, Line 15, Col 18, "This attribute is not valid for use on this language element");
- (Warning 842, Line 16, Col 3, Line 16, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 26, Col 3, Line 26, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 27, Col 3, Line 27, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 34, Col 3, Line 34, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 35, Col 3, Line 35, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 43, Col 3, Line 43, Col 18, "This attribute is not valid for use on this language element")
- (Warning 842, Line 44, Col 3, Line 44, Col 15, "This attribute is not valid for use on this language element")
- (Warning 842, Line 47, Col 3, Line 47, Col 14, "This attribute is not valid for use on this language element")
- (Warning 842, Line 48, Col 3, Line 48, Col 18, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 15, Col 3, Line 15, Col 18, "This attribute cannot be applied to class. Valid targets are: interface")
+ (Warning 842, Line 16, Col 3, Line 16, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
+ (Warning 842, Line 26, Col 3, Line 26, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 27, Col 3, Line 27, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
+ (Warning 842, Line 34, Col 3, Line 34, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 35, Col 3, Line 35, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
+ (Warning 842, Line 43, Col 3, Line 43, Col 18, "This attribute cannot be applied to class. Valid targets are: interface")
+ (Warning 842, Line 44, Col 3, Line 44, Col 15, "This attribute cannot be applied to class. Valid targets are: struct")
+ (Warning 842, Line 47, Col 3, Line 47, Col 14, "This attribute cannot be applied to struct. Valid targets are: class")
+ (Warning 842, Line 48, Col 3, Line 48, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface")
]
// SOURCE= CLIMutableAttribute01.fs # CLIMutableAttribute01.fs
@@ -760,9 +766,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
// SOURCE= E_AllowNullLiteral.fs # E_AllowNullLiteral.fs
[]
- let ``E_AllowNullLiteral 8.0`` compilation =
+ let ``E_AllowNullLiteral 9.0`` compilation =
compilation
- |> withLangVersion80
+ |> withLangVersion90
|> verifyCompile
|> shouldFail
|> withDiagnostics [
@@ -772,8 +778,8 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
(Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
(Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
(Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element")
- (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface")
+ (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface")
(Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal")
]
@@ -785,14 +791,14 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Error 935, Line 15, Col 10, Line 15, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal")
- (Error 934, Line 27, Col 10, Line 27, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Error 934, Line 30, Col 10, Line 30, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute")
- (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element")
- (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element")
+ (Error 935, Line 15, Col 10, Line 15, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal");
+ (Error 934, Line 27, Col 10, Line 27, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute");
+ (Error 934, Line 30, Col 10, Line 30, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute");
+ (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute");
+ (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute");
+ (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute");
+ (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface");
+ (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface");
(Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal")
]
diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs
index 6bb4761f7be..2b51fbf11f7 100644
--- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs
+++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs
@@ -61,7 +61,7 @@ module CustomAttributes_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 15, Col 7, Line 15, Col 17, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 15, Col 7, Line 15, Col 17, "This attribute cannot be applied to property, event, return value. Valid targets are: parameter")
]
// SOURCE=E_AttributeApplication04.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication04.fs
@@ -71,7 +71,8 @@ module CustomAttributes_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: parameter")
+ (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute cannot be applied to class. Valid targets are: parameter")
]
// SOURCE=E_AttributeApplication05.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication05.fs
diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs
index 38b84fb6498..926ea53bc34 100644
--- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs
+++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs
@@ -75,7 +75,7 @@ module EntryPoint =
|> compile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 9, Col 3, Line 9, Col 13, """This attribute is not valid for use on this language element""")
+ (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute cannot be applied to class. Valid targets are: method")
]
// SOURCE=E_twoattributesonsamefunction001.fs SCFLAGS="--test:ErrorRanges" # E_twoattributesonsamefunction001.fs
diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs
index d6fa3b02810..8595ef8e117 100644
--- a/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs
+++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs
@@ -48,7 +48,7 @@ module WithOOP =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
- (Warning 842, Line 8, Col 36, Line 8, Col 51, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 8, Col 36, Line 8, Col 51, "This attribute cannot be applied to type parameter. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate")
]
[]
diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs
index e876eef0906..d948c545dd6 100644
--- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs
+++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs
@@ -265,7 +265,7 @@ namespace N
|> compile
|> shouldFail
|> withDiagnostics [
- (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.");
+ (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.")
(Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M1' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.")
]
@@ -1465,7 +1465,7 @@ namespace N
|> compile
|> shouldFail
|> withDiagnostics [
- (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element")
+ (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
(Warning 3861, Line 7, Col 13, Line 7, Col 18, "The TailCall attribute should only be applied to recursive functions.")
]
@@ -1483,7 +1483,7 @@ namespace N
|> withLangVersion10
|> compile
|> shouldFail
- |> withSingleDiagnostic (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element")
+ |> withSingleDiagnostic (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute cannot be applied to property, field, return value. Valid targets are: method")
[]
let ``Warn about self-defined attribute`` () = // is the analysis available for users of older FSharp.Core versions
diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs
index 4c2451142fa..481d1cedb09 100644
--- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs
+++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs
@@ -177,7 +177,7 @@ let (|Foo|_|) x = ValueNone
let (|Foo|_|) x = ValueNone
"""
[|(FSharpDiagnosticSeverity.Warning, 842, (2, 3, 2, 9),
- "This attribute is not valid for use on this language element");
+ "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, struct, parameter, return value")
(FSharpDiagnosticSeverity.Error, 3350, (3, 6, 3, 13),
"Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater.")|]