From ae142c4c1bc90061672f6d8e59446147c3ff882e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 20 Jan 2025 20:44:21 +0000 Subject: [PATCH 01/11] support C# Experimental attribute --- src/Compiler/Checking/AttributeChecking.fs | 74 ++++++++++----- src/Compiler/Checking/AttributeChecking.fsi | 7 -- src/Compiler/Checking/PostInferenceChecks.fs | 2 +- src/Compiler/Driver/CompilerDiagnostics.fs | 5 +- src/Compiler/Facilities/DiagnosticsLogger.fs | 4 +- src/Compiler/Facilities/DiagnosticsLogger.fsi | 9 +- src/Compiler/Symbols/FSharpDiagnostic.fs | 13 +++ src/Compiler/Symbols/FSharpDiagnostic.fsi | 11 +++ src/Compiler/TypedTree/TcGlobals.fs | 1 + src/Compiler/TypedTree/TcGlobals.fsi | 2 + .../ExtendedDiagnosticDataTests.fs | 34 ++++++- .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../ExperimentalAttributeCheckingTests.fs | 92 +++++++++++++++++++ 13 files changed, 216 insertions(+), 39 deletions(-) mode change 100644 => 100755 tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index 8c317ad5f31..95b3fab35c7 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 = @@ -248,8 +241,9 @@ let private CheckCompilerFeatureRequiredAttribute (g: TcGlobals) cattrs msg m = CompleteD | _ -> ErrorD (ObsoleteDiagnostic(true, "", msg, "", m)) + -let private extractILObsoleteAttributeInfo namedArgs = +let private extractILAttributeInfo namedArgs = let extractILAttribValueFrom name namedArgs = match namedArgs with | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v @@ -258,24 +252,53 @@ let private extractILObsoleteAttributeInfo 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 the Message diagnosticId. + | Some ([ attribElement ], namedArgs) -> + let extractILAttribValueFrom name namedArgs = + match namedArgs with + | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v + | _ -> "" + + let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs + + let diagnosticId = + match attribElement with + | ILAttribElem.String (Some msg) -> msg + | ILAttribElem.String None + | _ -> "" + + WarnD(Experimental(FSComp.SR.experimentalConstruct (), diagnosticId, urlFormat, m)) + | Some (_, namedArgs) -> + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs + WarnD(Experimental(FSComp.SR.experimentalConstruct (), diagnosticId, urlFormat, m)) + // No arguments + | 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 @@ -284,7 +307,7 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs WarnD (ObsoleteDiagnostic(false, diagnosticId, msg, urlFormat, m)) | Some ([ILAttribElem.String (Some msg); ILAttribElem.Bool isError ], namedArgs) -> - let diagnosticId, urlFormat = extractILObsoleteAttributeInfo namedArgs + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs if isError then if g.langVersion.SupportsFeature(LanguageFeature.RequiredPropertiesSupport) then CheckCompilerFeatureRequiredAttribute g cattrs msg m @@ -294,15 +317,16 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs WarnD (ObsoleteDiagnostic(false, diagnosticId, msg, urlFormat, m)) // Only DiagnosticId, UrlFormat | Some (_, namedArgs) -> - let diagnosticId, urlFormat = extractILObsoleteAttributeInfo namedArgs + let diagnosticId, urlFormat = extractILAttributeInfo namedArgs WarnD(ObsoleteDiagnostic(false, diagnosticId, "", 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" @@ -366,7 +390,7 @@ 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) ])) -> @@ -376,9 +400,9 @@ let private CheckExperimentalAttribute g attribs m = else g.langVersion.IsPreviewEnabled && (s.IndexOf(langVersionPrefix, StringComparison.OrdinalIgnoreCase) >= 0) if not (isExperimentalAttributeDisabled s) then - do! WarnD(Experimental(s, m)) + do! WarnD(Experimental(s, "", "", m)) | Some _ -> - do! WarnD(Experimental(FSComp.SR.experimentalConstruct (), m)) + do! WarnD(Experimental(FSComp.SR.experimentalConstruct (), "", "", m)) | _ -> () } @@ -399,7 +423,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 } 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..7fc07b389c3 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, "", warningText, "", 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..036a2a036a7 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) @@ -1797,7 +1796,7 @@ type Exception with if s <> "" then os.AppendString(Obsolete2E().Format s) - | Experimental(s, _) -> os.AppendString(ExperimentalE().Format s) + | Experimental(message = s) -> os.AppendString(ExperimentalE().Format s) | PossibleUnverifiableCode _ -> os.AppendString(PossibleUnverifiableCodeE().Format) diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fs b/src/Compiler/Facilities/DiagnosticsLogger.fs index cf5c20fe84c..cfded5eb3c0 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 * diagnosticId: string * urlFormat: string * range: range exception PossibleUnverifiableCode of range: range @@ -133,6 +133,8 @@ 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 +exception ObsoleteDiagnostic of isError: bool * diagnosticId: string * message: string * urlFormat: string * 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..19690e903da 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 * diagnosticId: string * urlFormat: string * 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 * + message: string * + urlFormat: string * + 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..46306d13b15 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fs +++ b/src/Compiler/Symbols/FSharpDiagnostic.fs @@ -78,6 +78,16 @@ module ExtendedData = /// Represents the URL format of the diagnostic member this.UrlFormat: string = urlFormat + [] + type ExperimentalExtendedData + internal (diagnosticId: string, urlFormat: string) = + interface IFSharpDiagnosticExtendedData + /// Represents the DiagnosticId of the diagnostic + member this.DiagnosticId: string = diagnosticId + + /// Represents the URL format of the diagnostic + member this.UrlFormat: string = urlFormat + [] type TypeMismatchDiagnosticExtendedData internal (symbolEnv: SymbolEnv, dispEnv: DisplayEnv, expectedType: TType, actualType: TType, context: DiagnosticContextInfo) = @@ -214,6 +224,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..269b7835d2b 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fsi +++ b/src/Compiler/Symbols/FSharpDiagnostic.fsi @@ -61,6 +61,17 @@ module public ExtendedData = /// Represents the URL format of the diagnostic member UrlFormat: string + /// Additional data for diagnostics about obsolete attributes. + [] + type public ExperimentalExtendedData = + interface IFSharpDiagnosticExtendedData + + /// Represents the DiagnosticId of the diagnostic + member DiagnosticId: string + + /// Represents the URL format of the diagnostic + member UrlFormat: string + /// Additional data for type-mismatch-like (usually with ErrorNumber = 1) diagnostics [] type public TypeMismatchDiagnosticExtendedData = 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/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs old mode 100644 new mode 100755 index 23e4a9b9440..c1ba303b11c --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs @@ -541,4 +541,36 @@ let x = MyClass() (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("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("FS222", experimental.DiagnosticId) + Assert.Equal("", 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 100644 index 00000000000..1fa6a48d9c0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs @@ -0,0 +1,92 @@ +namespace Language + +open Xunit +open FSharp.Test.Compiler +open FSharp.Test + +module ExperimentalAttributeCheckingTests = + + [] + let ``Il Experimental attribute warning is taken into account(diagnosticId)`` () = + 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 ``Il Experimental 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, """Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + ] \ No newline at end of file From ef26e94961c935c683c37a9aa402b0ae39efae5d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 21 Jan 2025 18:45:47 +0000 Subject: [PATCH 02/11] FactForNETCOREAPP --- .../ExtendedDiagnosticDataTests.fs | 37 ++++++++++++++++++- .../ExperimentalAttributeCheckingTests.fs | 11 +++--- 2 files changed, 41 insertions(+), 7 deletions(-) mode change 100644 => 100755 tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs index c1ba303b11c..1bb58ffea50 100755 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs @@ -543,7 +543,7 @@ let x = MyClass() Assert.Equal("FS222", obsoleteDiagnostic.DiagnosticId) Assert.Equal("https://example.com", obsoleteDiagnostic.UrlFormat)) -[] +[] let ``Warning - ExperimentalExtendedData 01`` () = let CSLib = CSharp """ @@ -573,4 +573,37 @@ let text = Class1.Test(); (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") (fun (experimental: ExperimentalExtendedData) -> Assert.Equal("FS222", experimental.DiagnosticId) - Assert.Equal("", experimental.UrlFormat)) \ No newline at end of file + Assert.Equal("", 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("FS222", experimental.DiagnosticId) + Assert.Equal("https://example.com", experimental.UrlFormat)) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs old mode 100644 new mode 100755 index 1fa6a48d9c0..39c9ee5adb1 --- a/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs @@ -6,8 +6,9 @@ open FSharp.Test module ExperimentalAttributeCheckingTests = - [] - let ``Il Experimental attribute warning is taken into account(diagnosticId)`` () = + + [] + let ``Il Experimental(diagnosticId) attribute warning is taken into account`` () = let CSLib = CSharp """ using System.Diagnostics.CodeAnalysis; @@ -41,8 +42,8 @@ let text = Class1.Test() (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 ``Il Experimental attribute warning is taken into account`` () = + [] + let ``Il Experimental(UrlFormat) attribute warning is taken into account`` () = let CSLib = CSharp """ using System.Diagnostics.CodeAnalysis; @@ -76,7 +77,7 @@ let text = Class1.Test() (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 """ [] From 0daef9324d1f834f2399b09acafb43757d03cec3 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 21 Jan 2025 21:05:16 +0000 Subject: [PATCH 03/11] update baselines --- ...ompiler.Service.SurfaceArea.netstandard20.debug.bsl | 10 ++++++++++ ...piler.Service.SurfaceArea.netstandard20.release.bsl | 10 ++++++++++ 2 files changed, 20 insertions(+) mode change 100644 => 100755 tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl mode change 100644 => 100755 tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl 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..1313eaac9c0 --- 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 @@ -2861,6 +2861,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: 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: FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: 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..1313eaac9c0 --- 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 @@ -2861,6 +2861,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: 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: FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String DiagnosticId +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String UrlFormat +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String get_DiagnosticId() +FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: 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() From 19b9ebf45b5f299092bb2e62e8bbd636e2f1132d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 22 Jan 2025 11:07:13 +0000 Subject: [PATCH 04/11] More tests --- src/Compiler/Symbols/FSharpDiagnostic.fs | 1 + src/Compiler/Symbols/FSharpDiagnostic.fsi | 2 +- .../ExtendedDiagnosticDataTests.fs | 20 ++++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fs b/src/Compiler/Symbols/FSharpDiagnostic.fs index 46306d13b15..bc0530784d1 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fs +++ b/src/Compiler/Symbols/FSharpDiagnostic.fs @@ -78,6 +78,7 @@ module ExtendedData = /// Represents the URL format of the diagnostic member this.UrlFormat: string = urlFormat + /// Additional data for diagnostics about experimental attributes. [] type ExperimentalExtendedData internal (diagnosticId: string, urlFormat: string) = diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fsi b/src/Compiler/Symbols/FSharpDiagnostic.fsi index 269b7835d2b..bea8347ab09 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fsi +++ b/src/Compiler/Symbols/FSharpDiagnostic.fsi @@ -61,7 +61,7 @@ module public ExtendedData = /// Represents the URL format of the diagnostic member UrlFormat: string - /// Additional data for diagnostics about obsolete attributes. + /// Additional data for diagnostics about experimental attributes. [] type public ExperimentalExtendedData = interface IFSharpDiagnosticExtendedData diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs index 1bb58ffea50..259c517744d 100755 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs @@ -606,4 +606,22 @@ let text = Class1.Test(); (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") (fun (experimental: ExperimentalExtendedData) -> Assert.Equal("FS222", experimental.DiagnosticId) - Assert.Equal("https://example.com", experimental.UrlFormat)) \ No newline at end of file + Assert.Equal("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, """Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (fun (experimental: ExperimentalExtendedData) -> + Assert.Equal("", experimental.DiagnosticId) + Assert.Equal("", experimental.UrlFormat)) \ No newline at end of file From fa1e0374275bb38120adcbbdb2045073f8129f03 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 22 Jan 2025 21:07:40 +0000 Subject: [PATCH 05/11] Simplify logic --- src/Compiler/Checking/AttributeChecking.fs | 34 +++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index 95b3fab35c7..e43cc42098e 100755 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -242,12 +242,12 @@ let private CheckCompilerFeatureRequiredAttribute (g: TcGlobals) cattrs msg m = | _ -> ErrorD (ObsoleteDiagnostic(true, "", msg, "", m)) +let private extractILAttribValueFrom name namedArgs = + match namedArgs with + | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v + | _ -> "" let private extractILAttributeInfo namedArgs = - let extractILAttribValueFrom name namedArgs = - match namedArgs with - | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v - | _ -> "" let diagnosticId = extractILAttribValueFrom "DiagnosticId" namedArgs let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs (diagnosticId, urlFormat) @@ -259,26 +259,21 @@ let private CheckILExperimentalAttributes (g: TcGlobals) cattrs m = // [Experimental(diagnosticId: "DiagnosticId")] // [Experimental("DiagnosticId", UrlFormat = "UrlFormat")] // [Experimental(diagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")] - // Constructors the Message diagnosticId. + // Constructors deciding on DiagnosticId and UrlFormat properties. | Some ([ attribElement ], namedArgs) -> - let extractILAttribValueFrom name namedArgs = - match namedArgs with - | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> v - | _ -> "" - - let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs - let diagnosticId = match attribElement with | ILAttribElem.String (Some msg) -> msg | ILAttribElem.String None | _ -> "" + + let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs WarnD(Experimental(FSComp.SR.experimentalConstruct (), diagnosticId, urlFormat, m)) - | Some (_, namedArgs) -> - let diagnosticId, urlFormat = extractILAttributeInfo namedArgs - WarnD(Experimental(FSComp.SR.experimentalConstruct (), diagnosticId, urlFormat, m)) - // No arguments + // Empty constructor or only UrlFormat property are not allowed. + // [Experimental] + // [Experimental(UrlFormat = "UrlFormat")] + | Some _ | None -> CompleteD let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs m = @@ -401,10 +396,9 @@ let private CheckFSharpExperimentalAttribute g attribs m = g.langVersion.IsPreviewEnabled && (s.IndexOf(langVersionPrefix, StringComparison.OrdinalIgnoreCase) >= 0) if not (isExperimentalAttributeDisabled s) then do! WarnD(Experimental(s, "", "", m)) - | Some _ -> - do! WarnD(Experimental(FSComp.SR.experimentalConstruct (), "", "", m)) - | _ -> - () + // Empty constructor is not allowed. + | Some _ + | _ -> () } let private CheckUnverifiableAttribute g attribs m = From 3945fc714c58b5e29fb583907eb7e411f0b85dc0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 24 Jan 2025 11:51:31 +0000 Subject: [PATCH 06/11] Use None instead of "" to represent the absence of a property. --- src/Compiler/Checking/AttributeChecking.fs | 54 +++++++------- src/Compiler/Checking/PostInferenceChecks.fs | 2 +- src/Compiler/Driver/CompilerDiagnostics.fs | 20 ++++-- src/Compiler/FSStrings.resx | 10 ++- src/Compiler/Facilities/DiagnosticsLogger.fs | 10 ++- src/Compiler/Facilities/DiagnosticsLogger.fsi | 8 +-- src/Compiler/Symbols/FSharpDiagnostic.fs | 12 ++-- src/Compiler/Symbols/FSharpDiagnostic.fsi | 8 +-- src/Compiler/xlf/FSStrings.cs.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.de.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.es.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.fr.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.it.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.ja.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.ko.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.pl.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.pt-BR.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.ru.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.tr.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 20 ++++-- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 20 ++++-- .../ExtendedDiagnosticDataTests.fs | 70 +++++++++---------- .../ExperimentalAttributeCheckingTests.fs | 45 ++++++++++-- .../Warnings/ExperimentalAttributeTests.fs | 33 --------- tests/fsharp/FSharpSuite.Tests.fsproj | 1 - 25 files changed, 340 insertions(+), 193 deletions(-) delete mode 100644 tests/fsharp/Compiler/Warnings/ExperimentalAttributeTests.fs diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index e43cc42098e..f9c057fadc6 100755 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -240,12 +240,12 @@ 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) -> v - | _ -> "" + | ExtractILAttributeNamedArg name (AttribElemStringArg v) -> Some v + | _ -> None let private extractILAttributeInfo namedArgs = let diagnosticId = extractILAttribValueFrom "DiagnosticId" namedArgs @@ -263,16 +263,15 @@ let private CheckILExperimentalAttributes (g: TcGlobals) cattrs m = | Some ([ attribElement ], namedArgs) -> let diagnosticId = match attribElement with - | ILAttribElem.String (Some msg) -> msg + | ILAttribElem.String (Some msg) -> Some msg | ILAttribElem.String None - | _ -> "" - + | _ -> None + + let message = extractILAttribValueFrom "Message" namedArgs let urlFormat = extractILAttribValueFrom "UrlFormat" namedArgs - WarnD(Experimental(FSComp.SR.experimentalConstruct (), diagnosticId, urlFormat, m)) + WarnD(Experimental(message, diagnosticId, urlFormat, m)) // Empty constructor or only UrlFormat property are not allowed. - // [Experimental] - // [Experimental(UrlFormat = "UrlFormat")] | Some _ | None -> CompleteD @@ -296,12 +295,12 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs 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) -> + | Some ([ILAttribElem.String msg; ILAttribElem.Bool isError ], namedArgs) -> let diagnosticId, urlFormat = extractILAttributeInfo namedArgs if isError then if g.langVersion.SupportsFeature(LanguageFeature.RequiredPropertiesSupport) then @@ -313,7 +312,7 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs // Only DiagnosticId, UrlFormat | Some (_, namedArgs) -> let diagnosticId, urlFormat = extractILAttributeInfo namedArgs - WarnD(ObsoleteDiagnostic(false, diagnosticId, "", urlFormat, m)) + WarnD(ObsoleteDiagnostic(false, diagnosticId, None, urlFormat, m)) // No arguments | None -> CompleteD @@ -324,13 +323,11 @@ let private CheckILAttributes (g: TcGlobals) 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) @@ -350,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 -> () } @@ -388,14 +385,15 @@ let private CheckCompilerMessageAttribute 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)) + do! WarnD(Experimental(Some s, None, None, m)) // Empty constructor is not allowed. | Some _ | _ -> () @@ -426,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/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 7fc07b389c3..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(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 036a2a036a7..7124c5ce1ac 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -567,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", "") @@ -1790,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(message = 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 cfded5eb3c0..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 * diagnosticId: string * urlFormat: string * range: range +exception Experimental of message: string option * diagnosticId: string option * urlFormat: string option * range: range exception PossibleUnverifiableCode of range: range @@ -133,7 +133,13 @@ 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 -exception ObsoleteDiagnostic of isError: bool * diagnosticId: string * message: string * urlFormat: string * range: range +/// 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 19690e903da..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 * diagnosticId: string * urlFormat: string * range: range +exception Experimental of message: string option * diagnosticId: string option * urlFormat: string option * range: range exception PossibleUnverifiableCode of range: range @@ -89,9 +89,9 @@ exception DiagnosticWithSuggestions of exception ObsoleteDiagnostic of isError: bool * - diagnosticId: string * - message: string * - urlFormat: string * + diagnosticId: string option * + message: string option * + urlFormat: string option * range: range /// Creates a DiagnosticWithSuggestions whose text comes via SR.* diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fs b/src/Compiler/Symbols/FSharpDiagnostic.fs index bc0530784d1..da542902600 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fs +++ b/src/Compiler/Symbols/FSharpDiagnostic.fs @@ -70,24 +70,24 @@ 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, 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 [] type TypeMismatchDiagnosticExtendedData diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fsi b/src/Compiler/Symbols/FSharpDiagnostic.fsi index bea8347ab09..8c79ee95232 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fsi +++ b/src/Compiler/Symbols/FSharpDiagnostic.fsi @@ -56,10 +56,10 @@ 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. [] @@ -67,10 +67,10 @@ 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 type-mismatch-like (usually with ErrorNumber = 1) diagnostics [] 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 index 259c517744d..1c6003de003 100755 --- 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,8 +540,8 @@ let x = MyClass() |> checkDiagnostic (101, "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 - ExperimentalExtendedData 01`` () = @@ -572,8 +572,8 @@ let text = Class1.Test(); |> checkDiagnostic (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") (fun (experimental: ExperimentalExtendedData) -> - Assert.Equal("FS222", experimental.DiagnosticId) - Assert.Equal("", experimental.UrlFormat)) + Assert.Equal(Some "FS222", experimental.DiagnosticId) + Assert.Equal(None, experimental.UrlFormat)) [] @@ -605,8 +605,8 @@ let text = Class1.Test(); |> checkDiagnostic (57, """This construct is experimental. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") (fun (experimental: ExperimentalExtendedData) -> - Assert.Equal("FS222", experimental.DiagnosticId) - Assert.Equal("https://example.com", experimental.UrlFormat)) + Assert.Equal(Some "FS222", experimental.DiagnosticId) + Assert.Equal(Some "https://example.com", experimental.UrlFormat)) [] let ``Warning - ExperimentalExtendedData 03`` () = @@ -621,7 +621,7 @@ let text = Class1.Test(); """ |> typecheckResults |> checkDiagnostic - (57, """Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") + (57, """This construct is experimental. Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") (fun (experimental: ExperimentalExtendedData) -> - Assert.Equal("", experimental.DiagnosticId) - Assert.Equal("", experimental.UrlFormat)) \ No newline at end of file + Assert.Equal(None, experimental.DiagnosticId) + Assert.Equal(None, experimental.UrlFormat)) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs index 39c9ee5adb1..653aa488281 100755 --- a/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ExperimentalAttributeCheckingTests.fs @@ -7,8 +7,8 @@ open FSharp.Test module ExperimentalAttributeCheckingTests = - [] - let ``Il Experimental(diagnosticId) attribute warning is taken into account`` () = + [] + let ``C# Experimental(diagnosticId) attribute warning is taken into account`` () = let CSLib = CSharp """ using System.Diagnostics.CodeAnalysis; @@ -42,8 +42,8 @@ let text = Class1.Test() (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 ``Il Experimental(UrlFormat) attribute warning is taken into account`` () = + [] + let ``C# Experimental(UrlFormat) attribute warning is taken into account`` () = let CSLib = CSharp """ using System.Diagnostics.CodeAnalysis; @@ -77,7 +77,7 @@ let text = Class1.Test() (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 """ [] @@ -89,5 +89,36 @@ let text = Class1.Test() |> compile |> shouldFail |> withDiagnostics [ - (Warning 57, Line 6, Col 12, Line 6, Col 18, """Use with caution. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.""") - ] \ No newline at end of file + (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/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 @@ - From aa755221229564bd30f8414c87e4fc16f59f67ba Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 24 Jan 2025 13:45:50 +0000 Subject: [PATCH 07/11] Update test --- tests/fsharp/typecheck/sigs/neg91.bsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 35ea430cc7958114ed17402c57d9c1b8ff0a0c73 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 24 Jan 2025 14:01:07 +0000 Subject: [PATCH 08/11] update baselines --- ...r.Service.SurfaceArea.netstandard20.debug.bsl | 16 ++++++++-------- ...Service.SurfaceArea.netstandard20.release.bsl | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) 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 index 1313eaac9c0..cd2e1251576 100755 --- 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 @@ -2861,15 +2861,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: 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+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: System.String DiagnosticId -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String UrlFormat -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String get_DiagnosticId() -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: 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 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 index 1313eaac9c0..cd2e1251576 100755 --- 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 @@ -2861,15 +2861,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: 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+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: System.String DiagnosticId -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String UrlFormat -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: System.String get_DiagnosticId() -FSharp.Compiler.Diagnostics.ExtendedData+ExperimentalExtendedData: 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 From 3592c4311b84fb19c98fc9dff2d9329d312ae41f Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 7 Feb 2025 12:23:40 +0000 Subject: [PATCH 09/11] fix release notes --- docs/release-notes/.FSharp.Compiler.Service/9.0.300.md | 1 + 1 file changed, 1 insertion(+) 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 f41b4ca9289..9f9b2e0ae09 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -11,6 +11,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)) From c684a3693dd70374efb208f21d249685574bff62 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 7 Feb 2025 12:52:15 +0000 Subject: [PATCH 10/11] Update src/Compiler/Checking/AttributeChecking.fs Co-authored-by: Petr --- src/Compiler/Checking/AttributeChecking.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index f9c057fadc6..6e6cef5461b 100755 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -281,7 +281,7 @@ let private CheckILObsoleteAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs else let (AttribInfo(tref,_)) = g.attrib_SystemObsolete match TryDecodeILAttribute tref cattrs with - // [Obsolete>] + // [Obsolete] // [Obsolete("Message")] // [Obsolete("Message", true)] // [Obsolete("Message", DiagnosticId = "DiagnosticId")] From 121a5a8bf38bcdb8acb9d85d1ed7217c6f4617a5 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 7 Feb 2025 22:50:18 +0000 Subject: [PATCH 11/11] update bs --- ...harp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl | 5 ----- ...rp.Compiler.Service.SurfaceArea.netstandard20.release.bsl | 4 ---- 2 files changed, 9 deletions(-) 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 index cd2e1251576..1836a6673c1 100755 --- 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 @@ -2865,7 +2861,6 @@ FSharp.Compiler.Diagnostics.ExtendedData+ObsoleteDiagnosticExtendedData: Microso 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() 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 index cd2e1251576..fabaa710607 100755 --- 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