diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md index a6d29f078d4..4bc298ad5f5 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -12,6 +12,7 @@ ### Added * Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241)) * The 'use' keyword can be used on IDisposable|null without nullness warnings ([PR #18262](https://github.com/dotnet/fsharp/pull/18262)) +* Add support for C# `Experimental` attribute. ([PR #18253](https://github.com/dotnet/fsharp/pull/18253)) * Nullness warnings are issued for signature<>implementation conformance ([PR #18186](https://github.com/dotnet/fsharp/pull/18186)) * Symbols: Add FSharpAssembly.IsFSharp ([PR #18290](https://github.com/dotnet/fsharp/pull/18290)) diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index 8c317ad5f31..6e6cef5461b 100755 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -24,13 +24,6 @@ open FSharp.Compiler.TypeProviders open FSharp.Core.CompilerServices #endif -exception ObsoleteDiagnostic of - isError: bool * - diagnosticId: string * - message: string * - urlFormat: string * - range: range - let fail() = failwith "This custom attribute has an argument that cannot yet be converted using this API" let rec private evalILAttribElem elem = @@ -247,44 +240,68 @@ let private CheckCompilerFeatureRequiredAttribute (g: TcGlobals) cattrs msg m = | Some([ILAttribElem.String (Some featureName) ], _) when featureName = "RequiredMembers" -> CompleteD | _ -> - ErrorD (ObsoleteDiagnostic(true, "", msg, "", m)) + ErrorD (ObsoleteDiagnostic(true, None, msg, None, m)) + +let private extractILAttribValueFrom name namedArgs = + match namedArgs with + | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> Some v + | _ -> None -let private extractILObsoleteAttributeInfo namedArgs = - let extractILAttribValueFrom name namedArgs = - match namedArgs with - | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v - | _ -> "" +let private extractILAttributeInfo namedArgs = let diagnosticId = extractILAttribValueFrom "DiagnosticId" namedArgs let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs (diagnosticId, urlFormat) +let private CheckILExperimentalAttributes (g: TcGlobals) cattrs m = + let (AttribInfo(tref,_)) = g.attrib_IlExperimentalAttribute + match TryDecodeILAttribute tref cattrs with + // [Experimental("DiagnosticId")] + // [Experimental(diagnosticId: "DiagnosticId")] + // [Experimental("DiagnosticId", UrlFormat = "UrlFormat")] + // [Experimental(diagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")] + // Constructors deciding on DiagnosticId and UrlFormat properties. + | Some ([ attribElement ], namedArgs) -> + let diagnosticId = + match attribElement with + | ILAttribElem.String (Some msg) -> Some msg + | ILAttribElem.String None + | _ -> None + + let message = extractILAttribValueFrom "Message" namedArgs + let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs + + WarnD(Experimental(message, diagnosticId, urlFormat, m)) + // Empty constructor or only UrlFormat property are not allowed. + | Some _ + | None -> CompleteD + let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs m = if isByrefLikeTyconRef then CompleteD else let (AttribInfo(tref,_)) = g.attrib_SystemObsolete match TryDecodeILAttribute tref cattrs with - // [] - // [] - // [] - // [] - // [] - // [] - // [] - // [] - // [] + // [Obsolete] + // [Obsolete("Message")] + // [Obsolete("Message", true)] + // [Obsolete("Message", DiagnosticId = "DiagnosticId")] + // [Obsolete("Message", DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")] + // [Obsolete(DiagnosticId = "DiagnosticId")] + // [Obsolete(DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")] + // [Obsolete("Message", true, DiagnosticId = "DiagnosticId")] + // [Obsolete("Message", true, DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")] // Constructors deciding on IsError and Message properties. | Some ([ attribElement ], namedArgs) -> - let diagnosticId, urlFormat = extractILObsoleteAttributeInfo namedArgs + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs let msg = match attribElement with - | ILAttribElem.String (Some msg) -> msg + | ILAttribElem.String (Some msg) -> Some msg | ILAttribElem.String None - | _ -> "" + | _ -> None WarnD (ObsoleteDiagnostic(false, diagnosticId, msg, urlFormat, m)) - | Some ([ILAttribElem.String (Some msg); ILAttribElem.Bool isError ], namedArgs) -> - let diagnosticId, urlFormat = extractILObsoleteAttributeInfo namedArgs + | Some ([ILAttribElem.String msg; ILAttribElem.Bool isError ], namedArgs) -> + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs if isError then if g.langVersion.SupportsFeature(LanguageFeature.RequiredPropertiesSupport) then CheckCompilerFeatureRequiredAttribute g cattrs msg m @@ -294,24 +311,23 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs WarnD (ObsoleteDiagnostic(false, diagnosticId, msg, urlFormat, m)) // Only DiagnosticId, UrlFormat | Some (_, namedArgs) -> - let diagnosticId, urlFormat = extractILObsoleteAttributeInfo namedArgs - WarnD(ObsoleteDiagnostic(false, diagnosticId, "", urlFormat, m)) + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs + WarnD(ObsoleteDiagnostic(false, diagnosticId, None, urlFormat, m)) // No arguments | None -> CompleteD -/// Check IL attributes for 'ObsoleteAttribute', returning errors and warnings as data +/// Check IL attributes for Experimental, warnings as data let private CheckILAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs m = trackErrors { do! CheckILObsoleteAttributes g isByrefLikeTyconRef cattrs m + do! CheckILExperimentalAttributes g cattrs m } -let langVersionPrefix = "--langversion:preview" - let private extractObsoleteAttributeInfo namedArgs = let extractILAttribValueFrom name namedArgs = match namedArgs with - | ExtractAttribNamedArg name (AttribStringArg v) -> v - | _ -> "" + | ExtractAttribNamedArg name (AttribStringArg v) -> Some v + | _ -> None let diagnosticId = extractILAttribValueFrom "DiagnosticId" namedArgs let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs (diagnosticId, urlFormat) @@ -331,17 +347,17 @@ let private CheckObsoleteAttributes g attribs m = // Constructors deciding on IsError and Message properties. | Some(Attrib(unnamedArgs= [ AttribStringArg s ]; propVal= namedArgs)) -> let diagnosticId, urlFormat = extractObsoleteAttributeInfo namedArgs - do! WarnD(ObsoleteDiagnostic(false, diagnosticId, s, urlFormat, m)) + do! WarnD(ObsoleteDiagnostic(false, diagnosticId, Some s, urlFormat, m)) | Some(Attrib(unnamedArgs= [ AttribStringArg s; AttribBoolArg(isError) ]; propVal= namedArgs)) -> let diagnosticId, urlFormat = extractObsoleteAttributeInfo namedArgs if isError then - do! ErrorD (ObsoleteDiagnostic(true, diagnosticId, s, urlFormat, m)) + do! ErrorD (ObsoleteDiagnostic(true, diagnosticId, Some s, urlFormat, m)) else - do! WarnD (ObsoleteDiagnostic(false, diagnosticId, s, urlFormat, m)) + do! WarnD (ObsoleteDiagnostic(false, diagnosticId, Some s, urlFormat, m)) // Only DiagnosticId, UrlFormat | Some(Attrib(propVal= namedArgs)) -> let diagnosticId, urlFormat = extractObsoleteAttributeInfo namedArgs - do! WarnD(ObsoleteDiagnostic(false, diagnosticId, "", urlFormat, m)) + do! WarnD(ObsoleteDiagnostic(false, diagnosticId, None, urlFormat, m)) | None -> () } @@ -366,21 +382,21 @@ let private CheckCompilerMessageAttribute g attribs m = () } -let private CheckExperimentalAttribute g attribs m = +let private CheckFSharpExperimentalAttribute g attribs m = trackErrors { match TryFindFSharpAttribute g g.attrib_ExperimentalAttribute attribs with + // [] | Some(Attrib(unnamedArgs= [ AttribStringArg(s) ])) -> let isExperimentalAttributeDisabled (s:string) = if g.compilingFSharpCore then true else - g.langVersion.IsPreviewEnabled && (s.IndexOf(langVersionPrefix, StringComparison.OrdinalIgnoreCase) >= 0) + g.langVersion.IsPreviewEnabled && (s.IndexOf("--langversion:preview", StringComparison.OrdinalIgnoreCase) >= 0) if not (isExperimentalAttributeDisabled s) then - do! WarnD(Experimental(s, m)) - | Some _ -> - do! WarnD(Experimental(FSComp.SR.experimentalConstruct (), m)) - | _ -> - () + do! WarnD(Experimental(Some s, None, None, m)) + // Empty constructor is not allowed. + | Some _ + | _ -> () } let private CheckUnverifiableAttribute g attribs m = @@ -399,7 +415,7 @@ let CheckFSharpAttributes (g:TcGlobals) attribs m = trackErrors { do! CheckObsoleteAttributes g attribs m do! CheckCompilerMessageAttribute g attribs m - do! CheckExperimentalAttribute g attribs m + do! CheckFSharpExperimentalAttribute g attribs m do! CheckUnverifiableAttribute g attribs m } @@ -408,16 +424,16 @@ let CheckFSharpAttributes (g:TcGlobals) attribs m = let private CheckProvidedAttributes (g: TcGlobals) m (provAttribs: Tainted) = let (AttribInfo(tref, _)) = g.attrib_SystemObsolete match provAttribs.PUntaint((fun a -> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), tref.FullName)), m) with - | Some ([ Some (:? string as msg) ], _) -> WarnD(ObsoleteDiagnostic(false, "", msg, "", m)) + | Some ([ Some (:? string as msg) ], _) -> WarnD(ObsoleteDiagnostic(false, None, Some msg, None, m)) | Some ([ Some (:? string as msg); Some (:?bool as isError) ], _) -> if isError then - ErrorD (ObsoleteDiagnostic(true, "", msg, "", m)) + ErrorD (ObsoleteDiagnostic(true, None, Some msg, None, m)) else - WarnD (ObsoleteDiagnostic(false, "", msg, "", m)) + WarnD (ObsoleteDiagnostic(false, None, Some msg, None, m)) | Some ([ None ], _) -> - WarnD(ObsoleteDiagnostic(false, "", "", "", m)) + WarnD(ObsoleteDiagnostic(false, None, None, None, m)) | Some _ -> - WarnD(ObsoleteDiagnostic(false, "", "", "", m)) + WarnD(ObsoleteDiagnostic(false, None, None, None, m)) | None -> CompleteD #endif diff --git a/src/Compiler/Checking/AttributeChecking.fsi b/src/Compiler/Checking/AttributeChecking.fsi index 143763f889c..b23681702da 100644 --- a/src/Compiler/Checking/AttributeChecking.fsi +++ b/src/Compiler/Checking/AttributeChecking.fsi @@ -13,13 +13,6 @@ open FSharp.Compiler.TcGlobals open FSharp.Compiler.Text open FSharp.Compiler.TypedTree -exception ObsoleteDiagnostic of - isError: bool * - diagnosticId: string * - message: string * - urlFormat: string * - range: range - type AttribInfo = | FSAttribInfo of TcGlobals * Attrib | ILAttribInfo of TcGlobals * Import.ImportMap * ILScopeRef * ILAttribute * range diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index e8d6f5a5af0..3a4fe0e65ed 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -551,7 +551,7 @@ let WarnOnWrongTypeForAccess (cenv: cenv) env objName valAcc m ty = if isLessAccessible tyconAcc valAcc then let errorText = FSComp.SR.chkTypeLessAccessibleThanType(tcref.DisplayName, (objName())) |> snd let warningText = errorText + Environment.NewLine + FSComp.SR.tcTypeAbbreviationsCheckedAtCompileTime() - warning(AttributeChecking.ObsoleteDiagnostic(false, "", warningText, "", m)) + warning(ObsoleteDiagnostic(false, None, Some warningText, None, m)) CheckTypeDeep cenv (visitType, None, None, None, None) cenv.g env NoInfo ty diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 289d993e96e..7124c5ce1ac 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -14,7 +14,6 @@ open Internal.Utilities.Library open Internal.Utilities.Text open FSharp.Compiler -open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CheckExpressions open FSharp.Compiler.CheckDeclarations open FSharp.Compiler.CheckIncrementalClasses @@ -149,7 +148,7 @@ type Exception with | ValueRestriction(_, _, _, _, m) | LetRecUnsound(_, _, m) | ObsoleteDiagnostic(_, _, _, _, m) - | Experimental(_, m) + | Experimental(range = m) | PossibleUnverifiableCode m | UserCompilerMessage(_, _, m) | Deprecated(_, m) @@ -568,7 +567,9 @@ module OldStyleMessages = let ValNotLocalE () = Message("ValNotLocal", "") let Obsolete1E () = Message("Obsolete1", "") let Obsolete2E () = Message("Obsolete2", "%s") - let ExperimentalE () = Message("Experimental", "%s") + let Experimental1E () = Message("Experimental1", "") + let Experimental2E () = Message("Experimental2", "%s") + let Experimental3E () = Message("Experimental3", "") let PossibleUnverifiableCodeE () = Message("PossibleUnverifiableCode", "") let DeprecatedE () = Message("Deprecated", "%s") let LibraryUseOnlyE () = Message("LibraryUseOnly", "") @@ -1791,13 +1792,21 @@ type Exception with | ValNotLocal _ -> os.AppendString(ValNotLocalE().Format) - | ObsoleteDiagnostic(message = s) -> + | ObsoleteDiagnostic(message = message) -> os.AppendString(Obsolete1E().Format) - if s <> "" then - os.AppendString(Obsolete2E().Format s) + match message with + | Some message when message <> "" -> os.AppendString(Obsolete2E().Format message) + | _ -> () + + | Experimental(message = message) -> + os.AppendString(Experimental1E().Format) + + match message with + | Some message when message <> "" -> os.AppendString(Experimental2E().Format message) + | _ -> () - | Experimental(s, _) -> os.AppendString(ExperimentalE().Format s) + os.AppendString(Experimental3E().Format) | PossibleUnverifiableCode _ -> os.AppendString(PossibleUnverifiableCodeE().Format) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index e9338b6b990..abb2bb57f55 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1029,8 +1029,14 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + This construct is experimental + + + . {0} + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fs b/src/Compiler/Facilities/DiagnosticsLogger.fs index cf5c20fe84c..04cb35a2e8e 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fs +++ b/src/Compiler/Facilities/DiagnosticsLogger.fs @@ -108,7 +108,7 @@ exception LibraryUseOnly of range: range exception Deprecated of message: string * range: range -exception Experimental of message: string * range: range +exception Experimental of message: string option * diagnosticId: string option * urlFormat: string option * range: range exception PossibleUnverifiableCode of range: range @@ -133,6 +133,14 @@ exception DiagnosticWithSuggestions of number: int * message: string * range: ra /// A diagnostic that is raised when enabled manually, or by default with a language feature exception DiagnosticEnabledWithLanguageFeature of number: int * message: string * range: range * enabledByLangFeature: bool +/// A diagnostic that is raised when a diagnostic is obsolete +exception ObsoleteDiagnostic of + isError: bool * + diagnosticId: string option * + message: string option * + urlFormat: string option * + range: range + /// The F# compiler code currently uses 'Error(...)' in many places to create /// an DiagnosticWithText as an exception even if it's a warning. /// diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fsi b/src/Compiler/Facilities/DiagnosticsLogger.fsi index da7a6a66ca8..02471dd383b 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fsi +++ b/src/Compiler/Facilities/DiagnosticsLogger.fsi @@ -68,7 +68,7 @@ exception LibraryUseOnly of range: range exception Deprecated of message: string * range: range -exception Experimental of message: string * range: range +exception Experimental of message: string option * diagnosticId: string option * urlFormat: string option * range: range exception PossibleUnverifiableCode of range: range @@ -87,6 +87,13 @@ exception DiagnosticWithSuggestions of identifier: string * suggestions: Suggestions +exception ObsoleteDiagnostic of + isError: bool * + diagnosticId: string option * + message: string option * + urlFormat: string option * + range: range + /// Creates a DiagnosticWithSuggestions whose text comes via SR.* val ErrorWithSuggestions: (int * string) * range * string * Suggestions -> exn diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fs b/src/Compiler/Symbols/FSharpDiagnostic.fs index 66e077fba9c..da542902600 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fs +++ b/src/Compiler/Symbols/FSharpDiagnostic.fs @@ -70,14 +70,25 @@ module ExtendedData = /// Additional data for diagnostics about obsolete attributes. [] type ObsoleteDiagnosticExtendedData - internal (diagnosticId: string, urlFormat: string) = + internal (diagnosticId: string option, urlFormat: string option) = interface IFSharpDiagnosticExtendedData /// Represents the DiagnosticId of the diagnostic - member this.DiagnosticId: string = diagnosticId + member this.DiagnosticId: string option = diagnosticId /// Represents the URL format of the diagnostic - member this.UrlFormat: string = urlFormat + member this.UrlFormat: string option = urlFormat + /// Additional data for diagnostics about experimental attributes. + [] + type ExperimentalExtendedData + internal (diagnosticId: string option, urlFormat: string option) = + interface IFSharpDiagnosticExtendedData + /// Represents the DiagnosticId of the diagnostic + member this.DiagnosticId: string option = diagnosticId + + /// Represents the URL format of the diagnostic + member this.UrlFormat: string option = urlFormat + [] type TypeMismatchDiagnosticExtendedData internal (symbolEnv: SymbolEnv, dispEnv: DisplayEnv, expectedType: TType, actualType: TType, context: DiagnosticContextInfo) = @@ -214,6 +225,9 @@ type FSharpDiagnostic(m: range, severity: FSharpDiagnosticSeverity, message: str | ObsoleteDiagnostic(diagnosticId= diagnosticId; urlFormat= urlFormat) -> Some(ObsoleteDiagnosticExtendedData(diagnosticId, urlFormat)) + + | Experimental(diagnosticId= diagnosticId; urlFormat= urlFormat) -> + Some(ExperimentalExtendedData(diagnosticId, urlFormat)) | _ -> None let msg = diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fsi b/src/Compiler/Symbols/FSharpDiagnostic.fsi index ecee4c0540b..8c79ee95232 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fsi +++ b/src/Compiler/Symbols/FSharpDiagnostic.fsi @@ -56,10 +56,21 @@ module public ExtendedData = interface IFSharpDiagnosticExtendedData /// Represents the DiagnosticId of the diagnostic - member DiagnosticId: string + member DiagnosticId: string option /// Represents the URL format of the diagnostic - member UrlFormat: string + member UrlFormat: string option + + /// Additional data for diagnostics about experimental attributes. + [] + type public ExperimentalExtendedData = + interface IFSharpDiagnosticExtendedData + + /// Represents the DiagnosticId of the diagnostic + member DiagnosticId: string option + + /// Represents the URL format of the diagnostic + member UrlFormat: string option /// Additional data for type-mismatch-like (usually with ErrorNumber = 1) diagnostics [] diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index d8b95566717..93dd8905553 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -1562,6 +1562,7 @@ type TcGlobals( member val attrib_CompilerFeatureRequiredAttribute = findSysAttrib "System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute" member val attrib_SetsRequiredMembersAttribute = findSysAttrib "System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute" member val attrib_RequiredMemberAttribute = findSysAttrib "System.Runtime.CompilerServices.RequiredMemberAttribute" + member val attrib_IlExperimentalAttribute = findSysAttrib "System.Diagnostics.CodeAnalysis.ExperimentalAttribute" member g.improveType tcref tinst = improveTy tcref tinst diff --git a/src/Compiler/TypedTree/TcGlobals.fsi b/src/Compiler/TypedTree/TcGlobals.fsi index 772bc6b96d7..b172536d4f0 100644 --- a/src/Compiler/TypedTree/TcGlobals.fsi +++ b/src/Compiler/TypedTree/TcGlobals.fsi @@ -506,6 +506,8 @@ type internal TcGlobals = member attrib_WarnOnWithoutNullArgumentAttribute: BuiltinAttribInfo + member attrib_IlExperimentalAttribute: BuiltinAttribInfo + member attribs_Unsupported: FSharp.Compiler.TypedTree.TyconRef list member bitwise_and_info: IntrinsicValRef diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 20991832c18..698e7180ad6 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -37,6 +37,21 @@ Neshoda typů Očekává se řazená kolekce členů o délce {0} typu\n {1} \nale odevzdala se řazená kolekce členů o délce {2} typu\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Nejméně jedna informační zpráva v načteném souboru\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Toto upozornění se dá pomocí --nowarn:57 nebo #nowarn "57" vypnout. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Použití tohoto konstruktoru může způsobit vygenerování neověřitelného kódu .NET IL. Toto upozornění se dá pomocí --nowarn:9 nebo #nowarn "9" vypnout. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index b429cdd522c..ebfb525eb2a 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -37,6 +37,21 @@ Typenkonflikt. Es wurde ein Tupel der Länge {0} des Typs\n {1} \nerwartet, aber ein Tupel der Länge {2} des Typs\n {3}{4}\n angegeben. + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Mindestens eine Informationsmeldung in der geladenen Datei.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Diese Warnung kann mit "--nowarn 57" oder "#nowarn "57"" deaktiviert werden. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Die Verwendung dieses Konstrukts kann die Erzeugung von nicht verifizierbarem .NET-IL-Code zur Folge haben. Diese Warnung kann mit "--nowarn 9" oder "#nowarn "9"" deaktiviert werden. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 6620ac895f8..46816a23aba 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -37,6 +37,21 @@ Error de coincidencia de tipos. Se espera una tupla de longitud {0} de tipo\n {1} \nperero se ha proporcionado una tupla de longitud {2} de tipo\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Uno o más mensajes informativos en el archivo cargado.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Esta advertencia se puede deshabilitar con '--nowarn:57' o '#nowarn "57"'. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. El uso de esta construcción puede dar lugar a que se genere código .NET de IL que no se puede comprobar. Esta advertencia se puede deshabilitar con '--nowarn:9' o '#nowarn "9"'. diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index ac459e73f5b..7e8f9df4ee3 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -37,6 +37,21 @@ Incompatibilité de type. Tuple de longueur attendu {0} de type\n {1} \nmais tuple de longueur {2} de type\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Un ou plusieurs messages d’information dans le fichier chargé.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Cet avertissement peut être désactivé à l'aide de '--nowarn:57' ou '#nowarn "57"'. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Les utilisations de cette construction peuvent entraîner la génération de code IL (Intermediate Language) .NET non vérifiable. Cet avertissement peut être désactivé à l'aide de '--nowarn:9' ou '#nowarn "9"'. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 1f1ad15e05f..004e8d04e13 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -37,6 +37,21 @@ Tipo non corrispondente. È prevista una tupla di lunghezza {0} di tipo\n {1} \n, ma è stata specificata una tupla di lunghezza {2} di tipo\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Uno o più messaggi informativi nel file caricato.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Questo avviso può essere disabilitato mediante '--nowarn:57' o '#nowarn "57"'. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Gli utilizzi di questo costruttore potrebbero determinare la generazione di codice IL .NET non verificabile. Questo avviso può essere disabilitato mediante '--nowarn:9' o '#nowarn "9"'. diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 59d40979899..b7e4a21e670 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -37,6 +37,21 @@ 型が一致しません。型の長さ {0} のタプルが必要です\n {1} \nただし、型の長さ {2} のタプルが指定された場合\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n @@ -1547,11 +1562,6 @@ 。{0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}。この警告を無効にするには、'--nowarn:57' または '#nowarn "57"' を使用します。 - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. このコンストラクトを使用すると、検証できない .NET IL コードが生成される可能性があります。この警告を無効にするには、'--nowarn:9' または '#nowarn "9"' を使用してください。 diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 8ed60cc681f..edee12a29a2 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -37,6 +37,21 @@ 유형 불일치. 형식이 \n {1}이고 길이가 {0}인 튜플이 필요합니다. \n그러나 형식이 \n {3}이고 길이가 {2}인 튜플이 제공되었습니다.{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. 이 경고는 '--nowarn:57' 또는 '#nowarn "57"'을 통해 사용할 수 없도록 설정할 수 있습니다. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. 이 구문을 사용하면 확인할 수 없는 .NET IL 코드가 생성될 수 있습니다. 이 경고는 '--nowarn:9' 또는 '#nowarn "9"'를 통해 사용할 수 없도록 설정할 수 있습니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index c5f8bbc016b..b50fb8fc188 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -37,6 +37,21 @@ Niezgodność. Oczekiwano krotki o długości {0} typu\n {1} \nale otrzymano krotkę o długości {2} typu\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. To ostrzeżenie można wyłączyć przy użyciu elementu „--nowarn:57” lub „#nowarn "57"”. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Użycie tej konstrukcji może spowodować wygenerowanie kodu .NET IL, którego nie można zweryfikować. To ostrzeżenie można wyłączyć przy użyciu elementu „--nowarn:9” lub „#nowarn "9"”. diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 991d77016c9..f94ce79cd97 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -37,6 +37,21 @@ Tipo incompatível. Esperando uma tupla de comprimento {0} do tipo\n {1} \nmas recebeu uma tupla de comprimento {2} do tipo\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Uma ou mais mensagens informativas no arquivo carregado.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Este aviso foi desabilitado com o uso de '--nowarn:57' ou '#nowarn "57"'. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. O uso desse construto pode resultar na geração de código .NET IL não verificável. Este aviso pode ser desabilitado usando '--nowarn:9' ou '#nowarn "9"'. diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 2c4de5a755c..6df88d26d49 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -37,6 +37,21 @@ Несоответствие типов. Ожидается кортеж длиной {0} типа\n {1}, \nно предоставлен кортеж длиной {2} типа\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Одно или несколько информационных сообщений в загруженном файле.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Данное предупреждение можно отключить, используя --nowarn 57 или #nowarn "57". - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Использование данной конструкции может повлечь за собой создание непроверяемого кода .NET IL. Данное предупреждение можно отключить, используя --nowarn 9 или #nowarn "9". diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 7b936093a0d..59fc6b69625 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -37,6 +37,21 @@ Tür uyuşmazlığı. {0} uzunluğunda türü\n {1} \nolan bir demet bekleniyordu ancak {2} uzunluğunda türü\n {3}{4}\nolan bir demet verildi + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}. Bu uyarı, '--nowarn:57' veya '#nowarn "57"' kullanılarak devre dışı bırakılabilir. - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. Bu yapının kullanılması doğrulanamayan .NET IL kodunun oluşturulmasıyla sonuçlanabilir. Bu uyarı, '--nowarn:9' veya '#nowarn "9"' kullanılarak devre dışı bırakılabilir. diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 12afa253444..f97800458f1 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -37,6 +37,21 @@ 类型不匹配。应为长度为 {0} 的类型的元组\n {1} \n但提供了长度为 {2} 的类型的元组\n {3}{4}\n + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n 加载文件 .\n 中有一条或多条信息性消息 @@ -1547,11 +1562,6 @@ 。{0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}。可以使用“--nowarn:57”或“#nowarn "57"”禁用此警告。 - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. 使用此构造可能会导致生成不可验证的 .NET IL 代码。可以使用“--nowarn:9”或“#nowarn "9"”禁用此警告。 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 8e52040ed6f..2f0181b62d6 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -37,6 +37,21 @@ 類型不符。必須是類型為\n {1} \n 的元組長度 {0},但提供的是類型為\n {3}{4}\n 的元組長度 {2} + + This construct is experimental + This construct is experimental + + + + . {0} + . {0} + + + + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + . This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. + + One or more informational messages in loaded file.\n 已載入檔案中的一或多個資訊訊息。\n @@ -1547,11 +1562,6 @@ . {0} - - {0}. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. - {0}。使用 '--nowarn:57' 或 '#nowarn "57"' 可以停用這個警告。 - - Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'. 使用這個建構可能導致產生無法驗證的 .NET IL 程式碼。使用 '--nowarn:9' 或 '#nowarn "9"' 可以停用這個警告。 diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs old mode 100644 new mode 100755 index 23e4a9b9440..1c6003de003 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs @@ -256,8 +256,8 @@ let x = MyClass() |> checkDiagnostic (44, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 02`` () = @@ -272,8 +272,8 @@ let x = MyClass() |> checkDiagnostic (44, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 03`` () = @@ -288,8 +288,8 @@ let x = MyClass() |> checkDiagnostic (44, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(None, obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 04`` () = @@ -304,8 +304,8 @@ let x = MyClass() |> checkDiagnostic (44, "This construct is deprecated") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) [] @@ -336,8 +336,8 @@ let text = Class1.Test(); |> checkDiagnostic (44, "This construct is deprecated. Use something else") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 06`` () = @@ -367,8 +367,8 @@ let text = Class1.Test(); |> checkDiagnostic (44, "This construct is deprecated. Use something else") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 07`` () = @@ -398,8 +398,8 @@ let text = Class1.Test(); |> checkDiagnostic (44, "This construct is deprecated. Use something else") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(None, obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 08`` () = @@ -429,8 +429,8 @@ let text = Class1.Test(); |> checkDiagnostic (44, "This construct is deprecated") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 09`` () = @@ -445,8 +445,8 @@ let x = MyClass() |> checkDiagnostic (44, "This construct is deprecated") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(None, obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Warning - ObsoleteDiagnosticExtendedData 10`` () = @@ -476,8 +476,8 @@ let text = Class1.Test(); |> checkDiagnostic (44, "This construct is deprecated") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(None, obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Error - ObsoleteDiagnosticExtendedData 01`` () = @@ -492,8 +492,8 @@ let x = MyClass() |> checkDiagnostic (101, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) [] let ``Error - ObsoleteDiagnosticExtendedData 02`` () = @@ -508,8 +508,8 @@ let x = MyClass() |> checkDiagnostic (101, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Error - ObsoleteDiagnosticExtendedData 03`` () = @@ -524,8 +524,8 @@ let x = MyClass() |> checkDiagnostic (101, "This construct is deprecated. Message") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("", obsoleteDiagnostic.UrlFormat)) + Assert.Equal(None, obsoleteDiagnostic.DiagnosticId) + Assert.Equal(None, obsoleteDiagnostic.UrlFormat)) [] let ``Error - ObsoleteDiagnosticExtendedData 04`` () = @@ -540,5 +540,88 @@ let x = MyClass() |> checkDiagnostic (101, "This construct is deprecated") (fun (obsoleteDiagnostic: ObsoleteDiagnosticExtendedData) -> - Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) - Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) \ No newline at end of file + Assert.Equal(Some "FS222", obsoleteDiagnostic.DiagnosticId) + Assert.Equal(Some "https://example.com", obsoleteDiagnostic.UrlFormat)) + +[] +let ``Warning - ExperimentalExtendedData 01`` () = + let CSLib = + CSharp """ +using System.Diagnostics.CodeAnalysis; + +[Experimental(diagnosticId: "FS222")] +public static class Class1 +{ + public static string Test() + { + return "Hello"; + } +} + """ + |> withName "CSLib" + + let app = + FSharp """ +open MyLib + +let text = Class1.Test(); + """ |> withReferences [CSLib] + + app + |> typecheckResults + |> checkDiagnostic + (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (fun (experimental: ExperimentalExtendedData) -> + Assert.Equal(Some "FS222", experimental.DiagnosticId) + Assert.Equal(None, experimental.UrlFormat)) + + +[] +let ``Warning - ExperimentalExtendedData 02`` () = + let CSLib = + CSharp """ +using System.Diagnostics.CodeAnalysis; + +[Experimental(diagnosticId: "FS222", UrlFormat = "https://example.com")] +public static class Class1 +{ + public static string Test() + { + return "Hello"; + } +} + """ + |> withName "CSLib" + + let app = + FSharp """ +open MyLib + +let text = Class1.Test(); + """ |> withReferences [CSLib] + + app + |> typecheckResults + |> checkDiagnostic + (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (fun (experimental: ExperimentalExtendedData) -> + Assert.Equal(Some "FS222", experimental.DiagnosticId) + Assert.Equal(Some "https://example.com", experimental.UrlFormat)) + +[] +let ``Warning - ExperimentalExtendedData 03`` () = + FSharp """ +module Test + +[] +type Class1() = + static member Test() = "Hello" + +let text = Class1.Test(); + """ + |> typecheckResults + |> checkDiagnostic + (57, """This construct is experimental. Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (fun (experimental: ExperimentalExtendedData) -> + Assert.Equal(None, experimental.DiagnosticId) + Assert.Equal(None, experimental.UrlFormat)) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 9eb31c35e0d..60b867c7815 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -224,6 +224,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs new file mode 100755 index 00000000000..653aa488281 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs @@ -0,0 +1,124 @@ +namespace Language + +open Xunit +open FSharp.Test.Compiler +open FSharp.Test + +module ExperimentalAttributeCheckingTests = + + + [] + let ``C# Experimental(diagnosticId) attribute warning is taken into account`` () = + let CSLib = + CSharp """ +using System.Diagnostics.CodeAnalysis; + +namespace MyLib; + +[Experimental("MY001")] +public static class Class1 +{ + public static string Test() + { + return "Hello"; + } +} + """ + |> withCSharpLanguageVersion CSharpLanguageVersion.CSharp12 + |> withName "CSLib" + + let app = + Fsx """ +open MyLib + +let text = Class1.Test() + """ |> withReferences [CSLib] + + app + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 57, Line 4, Col 12, Line 4, Col 18, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (Warning 57, Line 4, Col 12, Line 4, Col 23, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + ] + + [] + let ``C# Experimental(UrlFormat) attribute warning is taken into account`` () = + let CSLib = + CSharp """ +using System.Diagnostics.CodeAnalysis; + +namespace MyLib; + +[Experimental("MY001", UrlFormat = "https://contoso.com/obsoletion-warnings")] +public static class Class1 +{ + public static string Test() + { + return "Hello"; + } +} + """ + |> withCSharpLanguageVersion CSharpLanguageVersion.CSharp12 + |> withName "CSLib" + + let app = + Fsx """ +open MyLib + +let text = Class1.Test() + """ |> withReferences [CSLib] + + app + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 57, Line 4, Col 12, Line 4, Col 18, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (Warning 57, Line 4, Col 12, Line 4, Col 23, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + ] + + [] + let ``F# Experimental attribute warning is taken into account`` () = + Fsx """ +[] +module Class1 = + let Test() = "Hello" + +let text = Class1.Test() + """ + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 57, Line 6, Col 12, Line 6, Col 18, """This construct is experimental. Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + ] + + [] + let ``ExperimentalAttribute nowarn when preview specified``() = + Fsx """ +module TestModule = + + [] + let getString = "A string" + + if getString = "A string" then () + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + + [] + let ``ExperimentalAttribute warn when preview not specified``() = + Fsx """ +module TestModule = + + [] + let getString = "A string" + + if getString = "A string" then () + """ + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 57, Line 7, Col 8, Line 7, Col 17, """This construct is experimental. Preview library feature, requires '--langversion:preview'. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + ] + \ No newline at end of file diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl old mode 100644 new mode 100755 index 198dcde56b2..1836a6673c1 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2836,10 +2836,6 @@ FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField SignatureField FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField get_ImplementationField() FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField get_SignatureField() -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String DiagnosticId -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String UrlFormat -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String get_DiagnosticId() -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String get_UrlFormat() FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: DiagnosticContextInfo ContextInfo FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: DiagnosticContextInfo get_ContextInfo() FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpDisplayContext DisplayContext @@ -2861,6 +2857,15 @@ FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedDa FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_UrlFormat() +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_UrlFormat() +FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnostic Create(FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity, System.String, Int32, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity Severity FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity get_Severity() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl old mode 100644 new mode 100755 index 198dcde56b2..fabaa710607 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2836,10 +2836,6 @@ FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField SignatureField FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField get_ImplementationField() FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpField get_SignatureField() -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String DiagnosticId -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String UrlFormat -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String get_DiagnosticId() -FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: System.String get_UrlFormat() FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: DiagnosticContextInfo ContextInfo FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: DiagnosticContextInfo get_ContextInfo() FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpDisplayContext DisplayContext @@ -2861,6 +2857,16 @@ FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedDa FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+TypeMismatchDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_UrlFormat() +FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_UrlFormat() +FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnostic Create(FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity, System.String, Int32, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity Severity FSharp.Compiler.Diagnostics.FSharpDiagnostic: FSharp.Compiler.Diagnostics.FSharpDiagnosticSeverity get_Severity() diff --git a/tests/fsharp/Compiler/Warnings/ExperimentalAttributeTests.fs b/tests/fsharp/Compiler/Warnings/ExperimentalAttributeTests.fs deleted file mode 100644 index 582ddf1ac06..00000000000 --- a/tests/fsharp/Compiler/Warnings/ExperimentalAttributeTests.fs +++ /dev/null @@ -1,33 +0,0 @@ -// 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 -open FSharp.Compiler.Diagnostics - - -module ``Validate ExperimentalAttribute and LanguageVersion`` = - - let experimentalSource = """ -module TestModule = - - [] - let getString = "A string" - - if getString = "A string" then () -""" - - [] - let ``ExperimentalAttribute nowarn when preview specified``() = - CompilerAssert.PassWithOptions - [| "--langversion:preview" |] - experimentalSource - - [] - let ``ExperimentalAttribute warn when preview not specified``() = - CompilerAssert.TypeCheckSingleError - experimentalSource - FSharpDiagnosticSeverity.Warning - 57 - (7, 8, 7, 17) - "Preview library feature, requires '--langversion:preview'. This warning can be disabled using '--nowarn:57' or '#nowarn \"57\"'." diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index fdbec7e88a6..32ff617c0d3 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -45,7 +45,6 @@ - diff --git a/tests/fsharp/typecheck/sigs/neg91.bsl b/tests/fsharp/typecheck/sigs/neg91.bsl index 559a4871f92..8cb3e21f836 100644 --- a/tests/fsharp/typecheck/sigs/neg91.bsl +++ b/tests/fsharp/typecheck/sigs/neg91.bsl @@ -9,7 +9,7 @@ neg91.fs(34,13,34,16): typecheck error FS0044: This construct is deprecated. Don neg91.fs(44,13,44,16): typecheck error FS3003: Don't touch me -neg91.fs(54,13,54,16): typecheck error FS0057: It was just an experiment!. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. +neg91.fs(54,13,54,16): typecheck error FS0057: This construct is experimental. It was just an experiment!. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'. neg91.fs(63,11,63,27): typecheck error FS3191: This literal pattern does not take arguments