Skip to content
Merged
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
22 changes: 15 additions & 7 deletions samples/OptionAnalyzer.Test/UnitTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ open NUnit.Framework
open FSharp.Compiler.Text
open FSharp.Analyzers.SDK
open FSharp.Analyzers.SDK.Testing
open FSharp.Analyzers.SDK

let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
let mutable runtimeTfm: string = Unchecked.defaultof<_>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has to be initialised inside SetUp, because of lazy initialisation of static members.


[<SetUp>]
[<OneTimeSetUp>]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to redo this before every test!

let Setup () =
runtimeTfm <-
let v = System.Environment.Version

"net"
+ string v.Major
+ "."
+ string v.Minor

task {
let! opts =
mkOptionsFromProject
"net8.0"
runtimeTfm
[
{
Name = "Newtonsoft.Json"
Expand Down Expand Up @@ -437,12 +445,12 @@ module ClientTests =
let file = { FileName = "A.fs"; Source = source }
getContextFor (TransparentCompilerOptions snapshot) [ file ] file

[<SetUp>]
[<OneTimeSetUp>]
let Setup () =
task {
let! opts =
mkSnapshotFromProject
"net8.0"
runtimeTfm
[
{
Name = "Newtonsoft.Json"
Expand Down Expand Up @@ -624,12 +632,12 @@ module ClientTests =

let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero

[<SetUp>]
[<OneTimeSetUp>]
let Setup () =
task {
let! opts =
mkOptionsFromProject
"net8.0"
runtimeTfm
[
{
Name = "Newtonsoft.Json"
Expand Down
Loading