File tree Expand file tree Collapse file tree
tests/FSharpLint.Core.Tests/Rules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ module Lint =
125125 GlobalConfig: Rules .GlobalRuleConfig
126126 TypeCheckResults: FSharpCheckFileResults option
127127 ProjectCheckResults: FSharpCheckProjectResults option
128+ ProjectOptions: Lazy < FSharpProjectOptions option >
128129 FilePath: string
129130 FileContent: string
130131 Lines: string []
@@ -149,6 +150,7 @@ module Lint =
149150 Lines = config.Lines
150151 CheckInfo = config.TypeCheckResults
151152 ProjectCheckInfo = config.ProjectCheckResults
153+ ProjectOptions = config.ProjectOptions
152154 GlobalConfig = config.GlobalConfig
153155 }
154156 // Build state for rules with context.
@@ -263,6 +265,10 @@ module Lint =
263265 GlobalConfig = enabledRules.GlobalConfig
264266 TypeCheckResults = fileInfo.TypeCheckResults
265267 ProjectCheckResults = fileInfo.ProjectCheckResults
268+ ProjectOptions = lazy (
269+ fileInfo.ProjectCheckResults
270+ |> Option.map _. ProjectContext.ProjectOptions
271+ )
266272 FilePath = fileInfo.File
267273 FileContent = fileInfo.Text
268274 Lines = lines
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ module Lint =
129129 GlobalConfig: Rules .GlobalRuleConfig
130130 TypeCheckResults: FSharpCheckFileResults option
131131 ProjectCheckResults: FSharpCheckProjectResults option
132+ ProjectOptions: Lazy < FSharpProjectOptions option >
132133 FilePath: string
133134 FileContent: string
134135 Lines: string []
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ type AstNodeRuleParams =
3131 Lines: string []
3232 CheckInfo: FSharpCheckFileResults option
3333 ProjectCheckInfo: FSharpCheckProjectResults option
34+ ProjectOptions: Lazy < FSharpProjectOptions option >
3435 GlobalConfig: GlobalRuleConfig }
3536
3637type LineRuleParams =
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ let runner (config: Config) (args: AstNodeRuleParams) =
3232 | _ -> config.Mode = AllAPIs
3333
3434 let likelyhoodOfBeingInLibrary =
35- match args.ProjectCheckInfo with
36- | Some projectInfo -> howLikelyProjectIsLibrary projectInfo.ProjectContext.ProjectOptions .ProjectFileName
35+ match args.ProjectOptions.Value with
36+ | Some projectOptions -> howLikelyProjectIsLibrary projectOptions .ProjectFileName
3737 | None -> Unlikely
3838
3939 if config.Mode = OnlyPublicAPIsInLibraries && likelyhoodOfBeingInLibrary <> Likely then
Original file line number Diff line number Diff line change @@ -205,8 +205,8 @@ let runner (config: Config) (args: AstNodeRuleParams) =
205205 Array.append ( checkFuncs asyncFuncs taskFuncs) ( checkFuncs taskFuncs asyncFuncs)
206206
207207 let likelyhoodOfBeingInLibrary =
208- match args.ProjectCheckInfo with
209- | Some projectInfo -> howLikelyProjectIsLibrary projectInfo.ProjectContext.ProjectOptions .ProjectFileName
208+ match args.ProjectOptions.Value with
209+ | Some projectOptions -> howLikelyProjectIsLibrary projectOptions .ProjectFileName
210210 | None -> Unlikely
211211
212212 if config.Mode = OnlyPublicAPIsInLibraries && likelyhoodOfBeingInLibrary <> Likely then
Original file line number Diff line number Diff line change @@ -95,9 +95,9 @@ let checkIfInLibrary (args: AstNodeRuleParams) (range: range) : array<WarningDet
9595 let ruleNotApplicable =
9696 isInObsoleteMethodOrFunction ( args.GetParents args.NodeIndex)
9797 ||
98- match ( args.CheckInfo, args.ProjectCheckInfo ) with
99- | Some checkFileResults, Some checkProjectResults ->
100- let projectFile = System.IO.FileInfo checkProjectResults.ProjectContext.ProjectOptions .ProjectFileName
98+ match ( args.CheckInfo, args.ProjectOptions.Value ) with
99+ | Some checkFileResults, Some projectOptions ->
100+ let projectFile = System.IO.FileInfo projectOptions .ProjectFileName
101101 match howLikelyProjectIsLibrary projectFile.Name with
102102 | Likely -> false
103103 | Unlikely -> true
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ type TestAstNodeRuleBase (rule:Rule) =
4343 GlobalConfig = resolvedGlobalConfig
4444 TypeCheckResults = checkResult
4545 ProjectCheckResults = None
46+ ProjectOptions = Lazy<_>( None)
4647 FilePath = ( Option.defaultValue String.Empty maybeFileName)
4748 FileContent = input
4849 Lines = ( input.Split( " \n " ))
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ type TestHintMatcherBase () =
6565 GlobalConfig = resolvedGlobalConfig
6666 TypeCheckResults = checkResult
6767 ProjectCheckResults = None
68+ ProjectOptions = Lazy<_>()
6869 FilePath = ( Option.defaultValue String.Empty maybeFileName)
6970 FileContent = input
7071 Lines = ( input.Split( " \n " ))
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ type TestIndentationRuleBase (rule:Rule) =
3838 GlobalConfig = resolvedGlobalConfig
3939 TypeCheckResults = None
4040 ProjectCheckResults = None
41+ ProjectOptions = Lazy<_>( None)
4142 FilePath = resolvedFileName
4243 FileContent = input
4344 Lines = lines
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ type TestLineRuleBase (rule:Rule) =
3838 GlobalConfig = resolvedGlobalConfig
3939 TypeCheckResults = None
4040 ProjectCheckResults = None
41+ ProjectOptions = Lazy<_>( None)
4142 FilePath = resolvedFileName
4243 FileContent = input
4344 Lines = lines
You can’t perform that action at this time.
0 commit comments