Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions samples/OptionAnalyzer.Test/UnitTests.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module OptionAnalyzer.Test

#nowarn "57"

open FSharp.Compiler.CodeAnalysis
open NUnit.Framework
open FSharp.Compiler.Text
Expand Down Expand Up @@ -429,13 +431,17 @@ module ClientTests =

module RunAnalyzersSafelyTests =

let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
let mutable projectOptions: FSharpProjectSnapshot = FSharpProjectSnapshot.zero

let getContext snapshot source =
let file = { FileName = "A.fs"; Source = source }
getContextFor (TransparentCompilerOptions snapshot) [ file ] file

[<SetUp>]
let Setup () =
task {
let! opts =
mkOptionsFromProject
mkSnapshotFromProject
"net8.0"
[
{
Expand Down Expand Up @@ -463,7 +469,10 @@ module ClientTests =
option.Value
"""

let ctx = getContext projectOptions source
let! ctx =
getContext projectOptions source
|> Async.AwaitTask

let client = new Client<CliAnalyzerAttribute, _>()
let path = System.IO.Path.GetFullPath(".")
let stats = client.LoadAnalyzers(path)
Expand Down Expand Up @@ -492,7 +501,10 @@ module ClientTests =
option.Value
"""

let ctx = getContext projectOptions source
let! ctx =
getContext projectOptions source
|> Async.AwaitTask

let client = new Client<CliAnalyzerAttribute, _>()
let path = System.IO.Path.GetFullPath(".")
let stats = client.LoadAnalyzers(path)
Expand Down Expand Up @@ -521,7 +533,10 @@ module ClientTests =
option.Value // fsharpanalyzer: ignore-line OV001
"""

let ctx = getContext projectOptions source
let! ctx =
getContext projectOptions source
|> Async.AwaitTask

let client = new Client<CliAnalyzerAttribute, _>()
let path = System.IO.Path.GetFullPath(".")
let stats = client.LoadAnalyzers(path)
Expand Down Expand Up @@ -551,7 +566,10 @@ module ClientTests =
option.Value
"""

let ctx = getContext projectOptions source
let! ctx =
getContext projectOptions source
|> Async.AwaitTask

let client = new Client<CliAnalyzerAttribute, _>()
let path = System.IO.Path.GetFullPath(".")
let stats = client.LoadAnalyzers(path)
Expand Down Expand Up @@ -582,7 +600,10 @@ module ClientTests =
// fsharpanalyzer: ignore-region-end
"""

let ctx = getContext projectOptions source
let! ctx =
getContext projectOptions source
|> Async.AwaitTask

let client = new Client<CliAnalyzerAttribute, _>()
let path = System.IO.Path.GetFullPath(".")
let stats = client.LoadAnalyzers(path)
Expand Down
Loading