Skip to content

Commit

Permalink
Merge pull request #134 from nojaf/fix-128
Browse files Browse the repository at this point in the history
Exclude type with generic arguments for StructDiscriminatedUnionAnalyzer allTypesArePrimitive check
  • Loading branch information
nojaf authored Jan 8, 2025
2 parents a67edf1 + 6c818e6 commit 250cea2
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.13.1 - 2024-01-08

### Fixed

* InvalidOperationException on some DUs. [#128](https://github.com/ionide/ionide-analyzers/issues/128)

## 0.13.0 - 2024-11-19

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ let private analyze

if ff.FieldType.IsFunctionType || ff.FieldType.IsAnonRecordType then
false
elif not (Seq.isEmpty ff.FieldType.GenericArguments) then
false
else

primitives.Contains ff.FieldType.BasicQualifiedName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let Setup () =
task {
let! opts =
mkOptionsFromProject
"net7.0"
"net8.0"
[
{
Name = "FSharp.Compiler.Service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []

projectOptions <- opts
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []

projectOptions <- opts
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []

projectOptions <- opts
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let messageString =
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []

projectOptions <- opts
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down Expand Up @@ -235,3 +235,18 @@ type Foo =
let! msgs = structDiscriminatedUnionCliAnalyzer ctx
Assert.That(msgs, Is.Empty)
}

[<Test>]
let ``negative: int array`` () =
async {
let source =
"""module Foo
type SingleCaseDU = | One of int[]
type TwoCaseDU = | Empty | Full of int[]
"""

let ctx = getContext projectOptions source
let! msgs = structDiscriminatedUnionCliAnalyzer ctx
Assert.That(msgs, Is.Empty)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let mutable projectOptions: FSharpProjectOptions = FSharpProjectOptions.zero
[<SetUp>]
let Setup () =
task {
let! opts = mkOptionsFromProject "net7.0" []
let! opts = mkOptionsFromProject "net8.0" []
projectOptions <- opts
}

Expand Down

0 comments on commit 250cea2

Please sign in to comment.