Skip to content
Open
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
2 changes: 2 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

```text
/
├── src/Cosmos.Json/ – System.Text.Json converters (FSharp.Azure.Cosmos.Json), no Azure Cosmos DB SDK
│ └── JsonConverters.fs – `TimeSpanTicksConverter`, which writes a `TimeSpan` as a number of ticks
├── src/Cosmos/ – main library (FSharp.Azure.Cosmos)
│ ├── SubStatusCodes.fs – documented Cosmos DB sub-status codes
│ ├── Cosmos.fs – core types and container extensions
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
* `TimeSpanTicksConverter`, a `System.Text.Json` converter that writes a `TimeSpan` as a JSON number of ticks. Cosmos DB sorts and compares a number in time order, but not the text that `System.Text.Json` writes (`"2.00:00:00"` sorts after `"10.00:00:00"`). The converter also reads that text, so old documents stay readable. See [How To store a duration](https://fsprojects.github.io/FSharp.Azure.Cosmos/How_Tos/Store_Durations.html)
* The package `FSharp.Azure.Cosmos.Json`, which contains the `System.Text.Json` converters. It does not use the Azure Cosmos DB SDK. Thus a project that does not reference the SDK can use the converters, for example a client of the API for Gremlin. `FSharp.Azure.Cosmos` depends on this package
* `TimeSpanTicksConverter` in the package `FSharp.Azure.Cosmos.Json`, a `System.Text.Json` converter that writes a `TimeSpan` as a JSON number of ticks. Cosmos DB sorts and compares a number in time order, but not the text that `System.Text.Json` writes (`"2.00:00:00"` sorts after `"10.00:00:00"`). The converter also reads that text, so old documents stay readable. See [How To store a duration](https://fsprojects.github.io/FSharp.Azure.Cosmos/How_Tos/Store_Durations.html)

### Changed
* BREAKING: the package targets `net10.0` only and no longer supports `net8.0`, which makes this a major release
Expand Down
1 change: 1 addition & 0 deletions FSharp.Azure.Cosmos.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"solution": {
"path": "FSharp.Azure.Cosmos.slnx",
"projects": [
"src\\Cosmos.Json\\FSharp.Azure.Cosmos.Json.fsproj",
"src\\Cosmos\\FSharp.Azure.Cosmos.fsproj",
"tests\\Cosmos.Tests.Infrastructure\\FSharp.Azure.Cosmos.Tests.Infrastructure.fsproj",
"tests\\Cosmos.Tests\\FSharp.Azure.Cosmos.Tests.fsproj"
Expand Down
1 change: 1 addition & 0 deletions FSharp.Azure.Cosmos.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<File Path="README.md" />
</Folder>
<Project Path="build/build.fsproj" />
<Project Path="src/Cosmos.Json/FSharp.Azure.Cosmos.Json.fsproj" />
<Project Path="src/Cosmos/FSharp.Azure.Cosmos.fsproj" />
<Project Path="tests/Cosmos.Tests.Infrastructure/FSharp.Azure.Cosmos.Tests.Infrastructure.fsproj" />
<Project Path="tests/Cosmos.Tests/FSharp.Azure.Cosmos.Tests.fsproj" />
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GitHub Actions |
Package | Stable | Prerelease
--- | --- | ---
FSharp.Azure.Cosmos | [![NuGet Badge](https://img.shields.io/nuget/v/FSharp.Azure.Cosmos.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos/) | [![NuGet Badge](https://img.shields.io/nuget/vpre/FSharp.Azure.Cosmos.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos/)
FSharp.Azure.Cosmos.Json | [![NuGet Badge](https://img.shields.io/nuget/v/FSharp.Azure.Cosmos.Json.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos.Json/) | [![NuGet Badge](https://img.shields.io/nuget/vpre/FSharp.Azure.Cosmos.Json.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos.Json/)

---

Expand Down
4 changes: 4 additions & 0 deletions docsSrc/How_Tos/Store_Durations.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ after both. A query with `ORDER BY` or with `>` on such a field gives the wrong
`TimeSpanTicksConverter` writes the number of ticks instead. One tick is 100 nanoseconds. Cosmos DB sorts and
compares a number in time order.

The converter is in the package `FSharp.Azure.Cosmos.Json`. `FSharp.Azure.Cosmos` depends on that package, thus a
project that references `FSharp.Azure.Cosmos` has the converter too. A project that does not use the Azure Cosmos DB
SDK can reference `FSharp.Azure.Cosmos.Json` alone.

## Use the converter

Add the converter to the options of System.Text.Json. Then give the options to the client. The camel case naming
Expand Down
23 changes: 23 additions & 0 deletions src/Cosmos.Json/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Auto-Generated by FAKE; do not edit
namespace System
open System.Reflection

[<assembly: AssemblyTitleAttribute("FSharp.Azure.Cosmos.Json")>]
[<assembly: AssemblyProductAttribute("FSharp.Azure.Cosmos")>]
[<assembly: AssemblyVersionAttribute("1.2.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2026-10-01T00:00:00.0000000+02:00")>]
[<assembly: AssemblyFileVersionAttribute("1.2.0")>]
[<assembly: AssemblyInformationalVersionAttribute("1.2.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","210cf041a0ce44fcc5a5df369550a77a1f75d436")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "FSharp.Azure.Cosmos.Json"
let [<Literal>] AssemblyProduct = "FSharp.Azure.Cosmos"
let [<Literal>] AssemblyVersion = "1.2.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2026-10-01T00:00:00.0000000+02:00"
let [<Literal>] AssemblyFileVersion = "1.2.0"
let [<Literal>] AssemblyInformationalVersion = "1.2.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "210cf041a0ce44fcc5a5df369550a77a1f75d436"
40 changes: 40 additions & 0 deletions src/Cosmos.Json/FSharp.Azure.Cosmos.Json.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
The converters do not use the Azure Cosmos DB SDK. Thus they are in a package of their own: a project that does
not reference the SDK can use them, for example a client of the API for Gremlin. FSharp.Azure.Cosmos references
this package.
-->
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>$(AssemblyBaseName).Json</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Deterministic>true</Deterministic>
</PropertyGroup>

<PropertyGroup Label="NuGet">
<PackageId>FSharp.Azure.Cosmos.Json</PackageId>
<Title>FSharp.Azure.Cosmos.Json</Title>
<Summary>System.Text.Json converters for the values that Azure Cosmos DB stores</Summary>
<Description>Provides System.Text.Json converters that write a value in a form that Azure Cosmos DB sorts and compares in the correct order, for example a TimeSpan as a number of ticks</Description>
<PackageTags>F#;FSharp;Cosmos;CosmosDB;Cosmos DB;System.Text.Json;JSON;Converter</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
</PropertyGroup>

<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="JsonConverters.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
File renamed without changes.
5 changes: 4 additions & 1 deletion src/Cosmos/FSharp.Azure.Cosmos.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<Compile Include="TaskSeq.fs" />
<Compile Include="CosmosResponse.fs" />
<Compile Include="SubStatusCodes.fs" />
<Compile Include="JsonConverters.fs" />
<Compile Include="Cosmos.fs" />
<Compile Include="Create.fs" />
<Compile Include="Upsert.fs" />
Expand All @@ -49,4 +48,8 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cosmos.Json\FSharp.Azure.Cosmos.Json.fsproj" />
</ItemGroup>

</Project>
Loading