Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ buildUnexpectedTypeArgs,"The non-generic type '%s' does not expect any type argu
returnUsedInsteadOfReturnBang,"Consider using 'return!' instead of 'return'."
yieldUsedInsteadOfYieldBang,"Consider using 'yield!' instead of 'yield'."
tupleRequiredInAbstractMethod,"\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface."
202,unsupportedAttribute,"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect."
203,buildInvalidWarningNumber,"Invalid warning number '%s'"
204,buildInvalidVersionString,"Invalid version string '%s'"
205,buildInvalidVersionFile,"Invalid version file '%s'"
Expand Down
4 changes: 3 additions & 1 deletion src/fsharp/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,9 @@ and CheckDecisionTreeTest cenv env m discrim =
| DecisionTreeTest.ActivePatternCase (exp, _, _, _, _, _) -> CheckExprNoByrefs cenv env exp
| DecisionTreeTest.Error _ -> ()

and CheckAttrib cenv env (Attrib(_, _, args, props, _, _, _)) =
and CheckAttrib cenv env (Attrib(tcref, _, args, props, _, _, m)) =
if List.exists (tyconRefEq cenv.g tcref) cenv.g.attribs_Unsupported then
warning(Error(FSComp.SR.unsupportedAttribute(), m))
props |> List.iter (fun (AttribNamedArg(_, _, _, expr)) -> CheckAttribExpr cenv env expr)
args |> List.iter (CheckAttribExpr cenv env)

Expand Down
4 changes: 4 additions & 0 deletions src/fsharp/TcGlobals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,10 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
member val attrib_CallerFilePathAttribute = findSysAttrib "System.Runtime.CompilerServices.CallerFilePathAttribute"
member val attrib_CallerMemberNameAttribute = findSysAttrib "System.Runtime.CompilerServices.CallerMemberNameAttribute"
member val attrib_SkipLocalsInitAttribute = findSysAttrib "System.Runtime.CompilerServices.SkipLocalsInitAttribute"
member val attribs_Unsupported = [
tryFindSysAttrib "System.Runtime.CompilerServices.ModuleInitializerAttribute"
tryFindSysAttrib "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute"
] |> List.choose (Option.map (fun x -> x.TyconRef))

member val attrib_ProjectionParameterAttribute = mk_MFCore_attrib "ProjectionParameterAttribute"
member val attrib_CustomOperationAttribute = mk_MFCore_attrib "CustomOperationAttribute"
Expand Down
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 @@ -607,6 +607,11 @@
<target state="translated">Zvažte použití parametru return! namísto return.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Pro odkazy na rozhraní .NET používejte referenční sestavení, pokud jsou k dispozici (ve výchozím nastavení povolené).</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 @@ -607,6 +607,11 @@
<target state="translated">Verwenden Sie ggf. "return!" anstelle von "return".</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Verweisassemblys für .NET Framework-Verweise verwenden, wenn verfügbar (standardmäßig aktiviert).</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 @@ -607,6 +607,11 @@
<target state="translated">Considere la posibilidad de usar "return!" en lugar de "return".</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Use ensamblados de referencia para las referencias de .NET Framework cuando estén disponibles (habilitado de forma predeterminada).</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 @@ -607,6 +607,11 @@
<target state="translated">Utilisez 'return!' à la place de 'return'.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Utilisez des assemblys de référence pour les références .NET Framework quand ils sont disponibles (activé par défaut).</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 @@ -607,6 +607,11 @@
<target state="translated">Provare a usare 'return!' invece di 'return'.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Usa gli assembly di riferimento per i riferimenti a .NET Framework quando disponibili (abilitato per impostazione predefinita).</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 @@ -607,6 +607,11 @@
<target state="translated">'return' の代わりに 'return!' を使うことを検討してください。</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">使用可能な場合は、.NET Framework リファレンスの参照アセンブリを使用します (既定で有効)。</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 @@ -607,6 +607,11 @@
<target state="translated">'return'이 아니라 'return!'를 사용하세요.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">기본적으로 활성화되는 참조 어셈블리를 .NET Framework 참조에 사용합니다(사용 가능한 경우).</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 @@ -607,6 +607,11 @@
<target state="translated">Rozważ użycie polecenia „return!” zamiast „return”.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Użyj zestawów odwołań dla odwołań do programu .NET Framework, gdy są dostępne (domyślnie włączone).</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 @@ -607,6 +607,11 @@
<target state="translated">Considere usar 'return!' em vez de 'return'.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Use assemblies de referência para referências do .NET Framework quando disponível (habilitado por padrão).</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 @@ -607,6 +607,11 @@
<target state="translated">Рекомендуется использовать "return!" вместо "return".</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Использовать базовые сборки для ссылок на платформу .NET, если базовые сборки доступны (включено по умолчанию).</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 @@ -607,6 +607,11 @@
<target state="translated">'return' yerine 'return!' kullanmayı deneyin.</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">Kullanılabilir olduğunda, .NET Framework başvuruları için başvuru bütünleştirilmiş kodlarını kullanın (Varsayılan olarak etkindir).</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 @@ -607,6 +607,11 @@
<target state="translated">考虑使用 "return!",而非 "return"。</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">如果可用,请对 .NET Framework 引用使用引用程序集(默认启用)。</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 @@ -607,6 +607,11 @@
<target state="translated">請考慮使用 'return!',而不使用 'return'。</target>
<note />
</trans-unit>
<trans-unit id="unsupportedAttribute">
<source>This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</source>
<target state="new">This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect.</target>
<note />
</trans-unit>
<trans-unit id="useSdkRefs">
<source>Use reference assemblies for .NET framework references when available (Enabled by default).</source>
<target state="translated">請在可行的情況下使用適用於 .NET 架構參考的參考組件 (預設會啟用)。</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.ErrorMessages

#if NETCOREAPP
open Xunit
open FSharp.Test.Utilities.Compiler

module ``Unsupported Attributes`` =

[<Fact>]
let ``Warn successfully`` () =
"""
open System.Runtime.CompilerServices
let f (w, [<CallerArgumentExpression "w">] x : string) = ()
let [<ModuleInitializer>] g () = ()
type C() =
member _.F (w, [<System.Runtime.CompilerServices.CallerArgumentExpression "w">] x : string) = ()
[<System.Runtime.CompilerServices.ModuleInitializer>]
member _.G() = ()
"""
|> FSharp
|> typecheck
|> shouldFail
|> withResults [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note - a less verbose withDiagnostics can be used here, for example, like in the ErrorMessages suite:

|> withDiagnostics [
(Error 767, Line 8, Col 16, Line 8, Col 23, "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement.")
(Error 17, Line 8, Col 18, Line 8, Col 21, "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method")
(Error 783, Line 6, Col 11, Line 6, Col 14, "At least one override did not correctly implement its corresponding abstract member")]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vzarytovskii How can I generate them? For withResults I can just copy from the test output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vzarytovskii How can I generate them? For withResults I can just copy from the test output.

I'm afraid, you'll have to write them manually :(
Let me see if I can serialise them into something which you can just copy-paste into withDiagnostics.

{ Error = Warning 202
Range = { StartLine = 3
StartColumn = 13
EndLine = 3
EndColumn = 37 }
Message =
"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect." }
{ Error = Warning 202
Range = { StartLine = 4
StartColumn = 7
EndLine = 4
EndColumn = 24 }
Message =
"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect." }
{ Error = Warning 202
Range = { StartLine = 6
StartColumn = 22
EndLine = 6
EndColumn = 78 }
Message =
"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect." }
{ Error = Warning 202
Range = { StartLine = 7
StartColumn = 7
EndLine = 7
EndColumn = 56 }
Message =
"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect." }
]
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Compile Include="EmittedIL\StringFormatAndInterpolation.fs" />
<Compile Include="EmittedIL\TailCalls.fs" />
<Compile Include="EmittedIL\TupleElimination.fs" />
<Compile Include="ErrorMessages\UnsupportedAttributes.fs" />
<Compile Include="ErrorMessages\TypeEqualsMissingTests.fs" />
<Compile Include="ErrorMessages\AccessOfTypeAbbreviationTests.fs" />
<Compile Include="ErrorMessages\AssignmentErrorTests.fs" />
Expand Down