Skip to content

Commit

Permalink
fix inline
Browse files Browse the repository at this point in the history
  • Loading branch information
goswinr committed Nov 1, 2024
1 parent 119c4eb commit f0efc2c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.0] - 2024-10-30
## [0.2.1] - 2024-10-30
### Changed
- Removed IDictionary and IEnumerable interface becaus not compatible with Fable JS & TS yet
- Unified API
Expand All @@ -22,8 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added more tests


[Unreleased]: https://github.com/goswinr/Dicts/compare/0.2.0...HEAD
[0.2.0]: https://github.com/goswinr/Dicts/compare/0.1.0...0.2.0
[Unreleased]: https://github.com/goswinr/Dicts/compare/0.2.1...HEAD
[0.2.0]: https://github.com/goswinr/Dicts/compare/0.1.0...0.2.1
[0.1.0]: https://github.com/goswinr/Dicts/releases/tag/0.1.0

<!--
Expand Down
12 changes: 10 additions & 2 deletions Src/DefaultDict.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ type DefaultDict<'K,'V when 'K:equality > private (defaultOfKeyFun: 'K -> 'V, ba
toString baseDic k v

/// A string representation of the DefaultDict including the count of entries and the first 5 entries.
member inline this.AsString = // inline needed for Fable
#if FABLE_COMPILER
member inline _.AsString = // inline needed for Fable reflection
#else
member _.AsString = // on .NET inline fails because it's using internal DefaultDictUtil
#endif
let b = Text.StringBuilder()
let c = baseDic.Count
let st = toString baseDic (typeof<'K>.Name) (typeof<'V>.Name)
Expand All @@ -140,7 +144,11 @@ type DefaultDict<'K,'V when 'K:equality > private (defaultOfKeyFun: 'K -> 'V, ba

/// A string representation of the DefaultDict including the count of entries
/// and the specified amount of entries.
member inline this.ToString(entriesToPrint) = // inline needed for Fable
#if FABLE_COMPILER
member inline _.ToString(entriesToPrint) = // inline needed for Fable reflection
#else
member _.ToString(entriesToPrint) = // on .NET inline fails because it's using internal DefaultDictUtil
#endif
let b = Text.StringBuilder()
let c = baseDic.Count
let st = toString baseDic (typeof<'K>.Name) (typeof<'V>.Name)
Expand Down
12 changes: 10 additions & 2 deletions Src/Dict.fs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ type Dict<'K,'V when 'K:equality > private (dic : Dictionary<'K,'V>) =


/// A string representation of the Dict including the count of entries and the first 5 entries.
member inline this.AsString = // inline needed for Fable
#if FABLE_COMPILER
member inline _.AsString = // inline needed for Fable reflection
#else
member _.AsString = // on .NET inline fails because it's using internal DefaultDictUtil
#endif
let b = Text.StringBuilder()
let c = dic.Count
let st = toString dic (typeof<'K>.Name) (typeof<'V>.Name)
Expand All @@ -215,7 +219,11 @@ type Dict<'K,'V when 'K:equality > private (dic : Dictionary<'K,'V>) =

/// A string representation of the Dict including the count of entries
/// and the specified amount of entries.
member inline this.ToString(entriesToPrint) = // inline needed for Fable
#if FABLE_COMPILER
member inline _.ToString(entriesToPrint) = // inline needed for Fable reflection
#else
member _.ToString(entriesToPrint) = // on .NET inline fails because it's using internal DefaultDictUtil
#endif
let b = Text.StringBuilder()
let c = dic.Count
let st = toString dic (typeof<'K>.Name) (typeof<'V>.Name)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ let tests =
let result = b.Get "A"
Expect.equal result 1 "DefaultDict should return the existing value when the key exists"

testCase "DefaultDict - default value" <| fun _ ->
testCase "DefaultDict - default value incr" <| fun _ ->
let b = DefaultDict(fun _ -> ref 0)
incr (b.Get "A")
Expect.equal b.["A"].Value 1 "DefaultDict should return the default value when the key does not exist"
Expand Down

0 comments on commit f0efc2c

Please sign in to comment.