Skip to content

Commit eda3992

Browse files
committed
add support for netstandard2.1 / net8 / net9
1 parent 70f2be5 commit eda3992

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Repository origins are:
2121

2222
## Supported platforms
2323

24-
This project targets `netstandard2.1` ([compatible runtimes](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-1#select-net-standard-version)).
24+
This project targets `.net 8`, `.net 9` and `netstandard2.1` ([compatible runtimes](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-1#select-net-standard-version))
25+
26+
:warning: NRT support starts with `.net sdk 9.0.200`. F# compiler in .net sdk 9.0.10x does not set correctly nullable attributes on F# types. NRT are not supported on `netstandard2.1`.
2527

2628
## Contributing
2729
* If you have a question about the library, then create an [issue][issues] with the `question` label.
@@ -89,7 +91,9 @@ NRT are serialized as:
8991
* `null` if `Null`
9092
* `object` if `NonNull` object
9193

92-
:warning: As of now, NRT can't be considered `null` when deserializing if value is missing.
94+
On deserialization, missing value is mapped to `null`.
95+
96+
:warning: NRT support starts with .net sdk 9.0.200. F# compiler in .net sdk 9.0.10x does not set correctly nullable attributes on F# types.
9397

9498
# License
9599
The contents of this library are made available under the [Apache License, Version 2.0][license].

src/FSharp.MongoDB.Bson/FSharp.MongoDB.Bson.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net9.0;net8.0;netstandard2.1</TargetFrameworks>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Nullable>enable</Nullable>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

src/FSharp.MongoDB.Bson/Serialization/FSharpTypeHelpers.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ module private Helpers =
2323

2424
let bindingFlags = BindingFlags.Public ||| BindingFlags.NonPublic
2525

26+
#if !NETSTANDARD2_1
2627
let nrtContext = NullabilityInfoContext()
28+
#endif
2729

2830
/// <summary>
2931
/// Returns <c>Some typ</c> when <c>pred typ</c> returns true, and <c>None</c> when
@@ -95,6 +97,10 @@ module private Helpers =
9597

9698
let mkMemberNullable (memberMap: BsonClassMap) (propertyInfo: PropertyInfo) =
9799
let memberMap = memberMap.MapMember(propertyInfo)
100+
#if !NETSTANDARD2_1
98101
let nrtInfo = nrtContext.Create(propertyInfo)
99102
if nrtInfo.WriteState = NullabilityState.Nullable then
100103
memberMap.SetDefaultValue(null).SetIsRequired(false) |> ignore
104+
#else
105+
()
106+
#endif

0 commit comments

Comments
 (0)