From 469b0af7240f4ffa70de3dea44ca282fa670e25a Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 9 Jan 2023 17:40:43 +0100 Subject: [PATCH 1/7] Warn is unused toplevel function is not included is signature file. --- src/Compiler/Checking/PostInferenceChecks.fs | 7 ++++- .../CompilerOptions/fsc/warnon/warnon.fs | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index b4eb42970a7..b81a3a63fa0 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -302,11 +302,16 @@ let BindVal cenv env (v: Val) = //printfn "binding %s..." v.DisplayName let alreadyDone = cenv.boundVals.ContainsKey v.Stamp cenv.boundVals[v.Stamp] <- 1 + + let notTopLevel () = + let parentHasSignature = v.DeclaringEntity.SigRange.FileName.EndsWith(".fsi") + not v.IsCompiledAsTopLevel || (parentHasSignature && v.SigRange.FileName.EndsWith(".fs")) + if not env.external && not alreadyDone && cenv.reportErrors && not v.HasBeenReferenced && - not v.IsCompiledAsTopLevel && + notTopLevel () && not (v.DisplayName.StartsWithOrdinal("_")) && not v.IsCompilerGenerated then diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs index 91322a0595d..65bde943fd0 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs @@ -34,3 +34,33 @@ module warnon = |> withDiagnosticMessageMatches "The value 'n' is unused$" |> ignore + [] + let ``warnon unused public function backed by signature file`` () = + let signatureFile: SourceCodeFileKind = + SourceCodeFileKind.Create( + "Library.fsi", + """ +module Foo + +val add: a:int -> b:int -> int + """ ) + + let implementationFile = + SourceCodeFileKind.Create( + "Library.fs", + """ +module Foo + +let add a b = a + b +let subtract a b = a - b + """ ) + + fsFromString signatureFile + |> FS + |> withAdditionalSourceFile implementationFile + |> withOptions ["--warnon:FS1182"] + |> asLibrary + |> compile + |> withWarningCode 1182 + |> withDiagnosticMessageMatches "The value 'subtract' is unused$" + |> ignore From a253e16fd30edf25120c83ca7936ce38aee1d843 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 11 Jan 2023 12:50:13 +0100 Subject: [PATCH 2/7] Add HasSignature to Val and Symbol.fs --- src/Compiler/Checking/PostInferenceChecks.fs | 6 +----- src/Compiler/Service/FSharpCheckerResults.fs | 4 +--- src/Compiler/Symbols/Symbols.fs | 8 ++++++++ src/Compiler/Symbols/Symbols.fsi | 3 +++ src/Compiler/TypedTree/TypedTree.fs | 3 +++ src/Compiler/TypedTree/TypedTree.fsi | 3 +++ ...p.Compiler.Service.SurfaceArea.netstandard20.debug.bsl | 2 ++ 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index b81a3a63fa0..97d52f47173 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -303,15 +303,11 @@ let BindVal cenv env (v: Val) = let alreadyDone = cenv.boundVals.ContainsKey v.Stamp cenv.boundVals[v.Stamp] <- 1 - let notTopLevel () = - let parentHasSignature = v.DeclaringEntity.SigRange.FileName.EndsWith(".fsi") - not v.IsCompiledAsTopLevel || (parentHasSignature && v.SigRange.FileName.EndsWith(".fs")) - if not env.external && not alreadyDone && cenv.reportErrors && not v.HasBeenReferenced && - notTopLevel () && + (not v.IsCompiledAsTopLevel || (v.IsCompiledAsTopLevel && not v.HasSignatureFile)) && not (v.DisplayName.StartsWithOrdinal("_")) && not v.IsCompilerGenerated then diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 61ba9c39c63..c66bb3e5142 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -270,9 +270,7 @@ type FSharpSymbolUse(denv: DisplayEnv, symbol: FSharpSymbol, inst: TyparInstanti let fileHasSignatureFile = fileSignatureLocation <> fileDeclarationLocation - let symbolIsNotInSignatureFile = m.SignatureLocation = Some m.DeclarationLocation - - fileHasSignatureFile && symbolIsNotInSignatureFile + fileHasSignatureFile && not m.HasSignatureFile || not m.IsModuleValueOrMember || m.Accessibility.IsPrivate | :? FSharpEntity as m -> m.Accessibility.IsPrivate diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index 480c58f3af6..56d19effb2a 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -1826,6 +1826,14 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | P _ -> true | _ -> false + member x.HasSignatureFile = + match fsharpInfo() with + | None -> false + | Some vref -> + match vref.TryDeref with + | ValueNone -> false + | ValueSome v -> v.HasSignatureFile + member _.IsEvent = match d with | E _ -> true diff --git a/src/Compiler/Symbols/Symbols.fsi b/src/Compiler/Symbols/Symbols.fsi index 8a38e2cb03e..e9ce9d8b11e 100644 --- a/src/Compiler/Symbols/Symbols.fsi +++ b/src/Compiler/Symbols/Symbols.fsi @@ -816,6 +816,9 @@ type FSharpMemberOrFunctionOrValue = /// Indicates if this is a method member member IsMethod: bool + /// Indicates if the value has a signature file counterpart + member HasSignatureFile: bool + /// Indicates if this is a property and there exists an associated getter method member HasGetterMethod: bool diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index dfdc9640a0c..9e54d3e9bd6 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -2803,6 +2803,9 @@ type Val = // Indicates if this value was declared to be a type function, e.g. "let f<'a> = typeof<'a>" member x.IsTypeFunction = x.val_flags.IsTypeFunction + member x.HasSignatureFile = + x.SigRange <> x.DefinitionRange + /// Get the inline declaration on the value member x.InlineInfo = x.val_flags.InlineInfo diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index b63942d2c8c..f6bdb0fb5ce 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -2085,6 +2085,9 @@ type Val = member IsTypeFunction: bool + /// Indicates if the value has a signature file counterpart + member HasSignatureFile: bool + /// The value of a value or member marked with [] member LiteralValue: Const option 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 a0c59428d2d..baf7e5a0770 100644 --- 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 @@ -4782,6 +4782,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean Equals(System.Obj FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean EventIsStandard FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasGetterMethod FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasSetterMethod +FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasSignatureFile FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsActivePattern FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsBaseValue FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsCompilerGenerated @@ -4814,6 +4815,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsValue FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_EventIsStandard() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasGetterMethod() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasSetterMethod() +FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasSignatureFile() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsActivePattern() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsBaseValue() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsCompilerGenerated() From e5c3e81a6aa0be2c8cf0036aa331388ea10e844d Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 11 Jan 2023 13:31:33 +0100 Subject: [PATCH 3/7] Verify the parent of the value has a signature file. --- src/Compiler/Checking/PostInferenceChecks.fs | 10 +++++++++- src/Compiler/TypedTree/TypedTree.fs | 2 ++ src/Compiler/TypedTree/TypedTree.fsi | 3 +++ .../CompilerOptions/fsc/warnon/warnon.fs | 20 +++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 97d52f47173..c23d048a0db 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -303,11 +303,19 @@ let BindVal cenv env (v: Val) = let alreadyDone = cenv.boundVals.ContainsKey v.Stamp cenv.boundVals[v.Stamp] <- 1 + let parentHasSignatureFile = + match v.TryDeclaringEntity with + | ParentNone -> false + | Parent p -> + match p.TryDeref with + | ValueNone -> false + | ValueSome e -> e.HasSignatureFile + if not env.external && not alreadyDone && cenv.reportErrors && not v.HasBeenReferenced && - (not v.IsCompiledAsTopLevel || (v.IsCompiledAsTopLevel && not v.HasSignatureFile)) && + (not v.IsCompiledAsTopLevel || (parentHasSignatureFile && v.IsCompiledAsTopLevel && not v.HasSignatureFile)) && not (v.DisplayName.StartsWithOrdinal("_")) && not v.IsCompilerGenerated then diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 9e54d3e9bd6..0adaac1f63e 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -1276,6 +1276,8 @@ type Entity = /// Indicates if we have pre-determined that a type definition has a self-referential constructor using 'as x' member x.HasSelfReferentialConstructor = x.entity_flags.HasSelfReferentialConstructor + + member x.HasSignatureFile = x.SigRange <> x.DefinitionRange /// Set the custom attributes on an F# type definition. member x.SetAttribs attribs = x.entity_attribs <- attribs diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index f6bdb0fb5ce..621a9da12bd 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -571,6 +571,9 @@ type Entity = /// Indicates if we have pre-determined that a type definition has a self-referential constructor using 'as x' member HasSelfReferentialConstructor: bool + /// Indicates if the value has a signature file counterpart + member HasSignatureFile: bool + /// Get the Abstract IL scope, nesting type metadata for this /// type definition, assuming it is backed by Abstract IL metadata. member ILTyconInfo: TILObjectReprData diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs index 65bde943fd0..a116c58d533 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs @@ -64,3 +64,23 @@ let subtract a b = a - b |> withWarningCode 1182 |> withDiagnosticMessageMatches "The value 'subtract' is unused$" |> ignore + + [] + let ``Don't warnon unused public function`` () = + let implementationFile = + SourceCodeFileKind.Create( + "Library.fs", + """ +module Foo + +let add a b = a + b +let subtract a b = a - b + """ ) + + fsFromString implementationFile + |> FS + |> withOptions ["--warnon:FS1182"] + |> asLibrary + |> compile + |> withDiagnostics [] + |> ignore From dfc1f762437a04ba40203bee2f43ecb02cd859ba Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 11 Jan 2023 13:58:17 +0100 Subject: [PATCH 4/7] Scope warning to let bindings only. --- src/Compiler/Checking/PostInferenceChecks.fs | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index c23d048a0db..50e5558d060 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -303,20 +303,23 @@ let BindVal cenv env (v: Val) = let alreadyDone = cenv.boundVals.ContainsKey v.Stamp cenv.boundVals[v.Stamp] <- 1 - let parentHasSignatureFile = - match v.TryDeclaringEntity with - | ParentNone -> false - | Parent p -> - match p.TryDeref with - | ValueNone -> false - | ValueSome e -> e.HasSignatureFile + let topLevelPublicLetBindingNotInSignatureFile () = + let parentHasSignatureFile () = + match v.TryDeclaringEntity with + | ParentNone -> false + | Parent p -> + match p.TryDeref with + | ValueNone -> false + | ValueSome e -> e.HasSignatureFile + + v.IsModuleBinding && parentHasSignatureFile () && not v.HasSignatureFile if not env.external && not alreadyDone && cenv.reportErrors && not v.HasBeenReferenced && - (not v.IsCompiledAsTopLevel || (parentHasSignatureFile && v.IsCompiledAsTopLevel && not v.HasSignatureFile)) && - not (v.DisplayName.StartsWithOrdinal("_")) && + (not v.IsCompiledAsTopLevel || topLevelPublicLetBindingNotInSignatureFile ()) && + not (v.DisplayName.StartsWithOrdinal("_")) && not v.IsCompilerGenerated then if v.IsCtorThisVal then From 6e3aa92759512e1933a81741cb56f7ec8112ce8e Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 16 Jan 2023 13:40:31 +0100 Subject: [PATCH 5/7] Apply feedback from code review. --- src/Compiler/Checking/PostInferenceChecks.fs | 6 ++-- .../CompilerOptions/fsc/warnon/warnon.fs | 36 +++++++++++++++++-- ...ervice.SurfaceArea.netstandard20.debug.bsl | 1 - 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 50e5558d060..bb833eebabd 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -303,7 +303,7 @@ let BindVal cenv env (v: Val) = let alreadyDone = cenv.boundVals.ContainsKey v.Stamp cenv.boundVals[v.Stamp] <- 1 - let topLevelPublicLetBindingNotInSignatureFile () = + let topLevelBindingHiddenBySignatureFile () = let parentHasSignatureFile () = match v.TryDeclaringEntity with | ParentNone -> false @@ -312,13 +312,13 @@ let BindVal cenv env (v: Val) = | ValueNone -> false | ValueSome e -> e.HasSignatureFile - v.IsModuleBinding && parentHasSignatureFile () && not v.HasSignatureFile + v.IsModuleBinding && not v.HasSignatureFile && parentHasSignatureFile () if not env.external && not alreadyDone && cenv.reportErrors && not v.HasBeenReferenced && - (not v.IsCompiledAsTopLevel || topLevelPublicLetBindingNotInSignatureFile ()) && + (not v.IsCompiledAsTopLevel || topLevelBindingHiddenBySignatureFile ()) && not (v.DisplayName.StartsWithOrdinal("_")) && not v.IsCompilerGenerated then diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs index a116c58d533..76b7005dd4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs @@ -35,7 +35,7 @@ module warnon = |> ignore [] - let ``warnon unused public function backed by signature file`` () = + let ``warnon unused public function hidden by signature file`` () = let signatureFile: SourceCodeFileKind = SourceCodeFileKind.Create( "Library.fsi", @@ -54,7 +54,7 @@ module Foo let add a b = a + b let subtract a b = a - b """ ) - + fsFromString signatureFile |> FS |> withAdditionalSourceFile implementationFile @@ -76,7 +76,7 @@ module Foo let add a b = a + b let subtract a b = a - b """ ) - + fsFromString implementationFile |> FS |> withOptions ["--warnon:FS1182"] @@ -84,3 +84,33 @@ let subtract a b = a - b |> compile |> withDiagnostics [] |> ignore + + [] + let ``Don't warnon unused public function hidden by signature file that starts with an underscore`` () = + let signatureFile: SourceCodeFileKind = + SourceCodeFileKind.Create( + "Library.fsi", + """ +module Foo + +val add: a:int -> b:int -> int + """ ) + + let implementationFile = + SourceCodeFileKind.Create( + "Library.fs", + """ +module Foo + +let add a b = a + b +let _subtract a b = a - b + """ ) + + fsFromString signatureFile + |> FS + |> withAdditionalSourceFile implementationFile + |> withOptions ["--warnon:FS1182"] + |> asLibrary + |> compile + |> withDiagnostics [] + |> ignore 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 baf7e5a0770..a968aad5932 100644 --- 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 @@ -2012,7 +2012,6 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: FSharp.Compiler.Symbols. FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] get_DependencyFiles() -FSharp.Compiler.CodeAnalysis.FSharpChecker FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Instance FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker get_Instance() From 8c42164793e69508727c33f902d1cb1c26c14799 Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 16 Jan 2023 16:21:48 +0100 Subject: [PATCH 6/7] Surface Area Release mode --- ...Sharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl | 2 ++ 1 file changed, 2 insertions(+) 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 55bf9244652..a968aad5932 100644 --- 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 @@ -4781,6 +4781,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean Equals(System.Obj FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean EventIsStandard FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasGetterMethod FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasSetterMethod +FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean HasSignatureFile FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsActivePattern FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsBaseValue FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsCompilerGenerated @@ -4813,6 +4814,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsValue FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_EventIsStandard() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasGetterMethod() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasSetterMethod() +FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_HasSignatureFile() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsActivePattern() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsBaseValue() FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsCompilerGenerated() From c2c967ee252996540034f4072ba3c3edd4175f9b Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 19 Jan 2023 18:24:02 +0100 Subject: [PATCH 7/7] Add test for type extension. --- .../CompilerOptions/fsc/warnon/warnon.fs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs index 76b7005dd4e..6c23e82e288 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs @@ -114,3 +114,31 @@ let _subtract a b = a - b |> compile |> withDiagnostics [] |> ignore + + [] + let ``Type extensions are not included in this warnon check`` () = + let signatureFile: SourceCodeFileKind = + SourceCodeFileKind.Create( + "Library.fsi", + """ +module Foo + """ ) + + let implementationFile = + SourceCodeFileKind.Create( + "Library.fs", + """ +module Foo + +type System.Int32 with + member x.Bar () = x + 1 + """ ) + + fsFromString signatureFile + |> FS + |> withAdditionalSourceFile implementationFile + |> withOptions ["--warnon:FS1182"] + |> asLibrary + |> compile + |> shouldSucceed + |> ignore