Skip to content
Merged
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
46 changes: 26 additions & 20 deletions .github/workflows/build_nuget_dont_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,33 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
10.0.x
9.0.x
8.0.x

- name: Extract version from tag
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore -c Release
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
11.0.x
10.0.x

- name: Set version
shell: bash
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
if [ -z "$VERSION" ] || [ "$VERSION" = "main" ]; then
VERSION="0.0.0-local"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore -c Release

# - name: Test
# run: dotnet test --no-build

- name: Pack
run: dotnet pack --no-build -c Release -o nupkg -p:Version=${{ env.VERSION }}
- name: Pack
run: dotnet pack --no-build -c Release -o nupkg -p:Version=${{ env.VERSION }}
3 changes: 1 addition & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
11.0.x
10.0.x
9.0.x
8.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
87 changes: 67 additions & 20 deletions .github/workflows/publish_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,80 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
10.0.x
9.0.x
8.0.x
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
11.0.x
10.0.x

- name: Extract version from tag
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV
- name: Extract version from tag
shell: bash
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"

- name: Restore dependencies
run: dotnet restore
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore -c Release
- name: Build
run: dotnet build --no-restore -c Release

# - name: Test
# run: dotnet test --no-build
- name: Pack
run: dotnet pack --no-build -c Release -o nupkg -p:Version=${{ env.VERSION }}

- name: Pack
run: dotnet pack --no-build -c Release -o nupkg -p:Version=${{ env.VERSION }}
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: nupkg/*
if-no-files-found: error

- name: Publish
run: dotnet nuget push "nupkg/*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
publish:
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
id-token: write

steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
11.0.x
10.0.x

- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: nupkg

- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}

- name: Publish package
id: publish_package
continue-on-error: true
run: dotnet nuget push "nupkg/*.nupkg" --skip-duplicate --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" -s https://api.nuget.org/v3/index.json

- name: Publish symbols
id: publish_symbols
continue-on-error: true
run: dotnet nuget push "nupkg/*.snupkg" --skip-duplicate --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" -s https://api.nuget.org/v3/index.json

- name: Warn about publish credential failure
if: steps.publish_package.outcome == 'failure' || steps.publish_symbols.outcome == 'failure'
run: |
echo "::warning::NuGet publish failed because the configured credential was rejected. The build completed successfully and the generated packages were uploaded as workflow artifacts for manual publishing after the NuGet credential is rotated."
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<DefaultTargetFrameworks>net8.0;net9.0;net10.0</DefaultTargetFrameworks>
<DefaultTargetFrameworks>net10.0;net11.0</DefaultTargetFrameworks>
<OutputType>Library</OutputType>
<Nullable>enable</Nullable>
<LangVersion>Latest</LangVersion>
Expand All @@ -11,7 +11,7 @@
<Product>Domain Primitives</Product>
<Company>ALTA Software llc.</Company>
<Copyright>Copyright © 2024 ALTA Software llc.</Copyright>
<Version>8.1.3</Version>
<Version>9.0.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
19 changes: 13 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.*" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.2.*" />
<PackageVersion Include="Microsoft.OpenApi" Version="2.12.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.1" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.*" />
<PackageVersion Include="Verify.Xunit" Version="31.12.5" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.0" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.*" />
<PackageVersion Include="Microsoft.OpenApi" Version="2.*" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.3.*" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="11.0.*" />
<PackageVersion Include="Microsoft.OpenApi" Version="3.*" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerGen" Version="11.0.*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<!--<TargetFramework>net9.0</TargetFramework>-->
<TargetFrameworks>net10.0;net11.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
Expand All @@ -17,16 +16,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Scalar.AspNetCore" Version="2.16.12" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.10" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.3" />
<PackageReference Include="Scalar.AspNetCore" Version="2.20.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<ProjectReference Include="..\..\src\AltaSoft.DomainPrimitives.OpenApiExtensions\AltaSoft.DomainPrimitives.OpenApiExtensions.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.*" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.3.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="11.0.*" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="11.0.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AltaSoft.DomainPrimitives.OpenApiExtensions\AltaSoft.DomainPrimitives.OpenApiExtensions.csproj" />
<ProjectReference Include="..\..\src\AltaSoft.DomainPrimitives.SwaggerExtensions\AltaSoft.DomainPrimitives.SwaggerExtensions.csproj" />
<ProjectReference Include="..\DomainPrimitivesDemo\DomainPrimitivesDemo.csproj" />
</ItemGroup>
Expand Down
10 changes: 7 additions & 3 deletions Examples/DomainPrimitivesDemo/DomainPrimitivesDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net10.0;net9.0</TargetFrameworks>
<TargetFrameworks>net10.0;net11.0</TargetFrameworks>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.OpenApi" Version="2.9.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.OpenApi" Version="2.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.OpenApi" Version="3.*" />
</ItemGroup>


Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DomainPrimitives for C#

[![Version](https://img.shields.io/nuget/v/AltaSoft.DomainPrimitives?label=Version&color=0c3c60&style=for-the-badge&logo=nuget)](https://www.nuget.org/profiles/AltaSoft)
[![Dot NET 8+](https://img.shields.io/static/v1?label=DOTNET&message=8%2B&color=0c3c60&style=for-the-badge)](https://dotnet.microsoft.com)
[![Dot NET 10+](https://img.shields.io/static/v1?label=DOTNET&message=10%2B&color=0c3c60&style=for-the-badge)](https://dotnet.microsoft.com)

# Table of Contents

Expand Down Expand Up @@ -38,6 +38,16 @@ With `AltaSoft.DomainPrimitives`, experience an accelerated development process

## What's New

### .NET 11 Support

The library now targets `net10.0` and `net11.0`. Support for .NET 8 and .NET 9 has been dropped.

* **Framework-specific dependencies:** Packages that ship separate builds per .NET version are resolved per target framework:
- `net10.0`: `Microsoft.AspNetCore.OpenApi` 10.x, `Microsoft.OpenApi` 2.x, `Swashbuckle.AspNetCore.SwaggerGen` 10.x
- `net11.0`: `Microsoft.AspNetCore.OpenApi` 11.x, `Microsoft.OpenApi` 3.x, `Swashbuckle.AspNetCore.SwaggerGen` 11.x
* **OpenAPI Extensions:** `AltaSoft.DomainPrimitives.OpenApiExtensions` now targets both `net10.0` and `net11.0`.
* **OpenAPI schema examples:** The `<example>` XML doc value is now emitted into the generated `OpenApiHelper` as `OpenApiSchema.Examples` instead of the obsolete `Example` property. `AltaSoft.DomainPrimitives.SwaggerExtensions` now references `Microsoft.OpenApi` directly (latest 2.x on `net10.0`, latest 3.x on `net11.0`) so examples are also written for OpenAPI 3.0 documents.

### Flexible Date & Time Parsing / Deserialization

Parsing and deserialization for `DateOnly`, `DateTime`, `DateTimeOffset`, `TimeOnly`, and `TimeSpan` domain primitives has been significantly improved:
Expand Down Expand Up @@ -138,7 +148,7 @@ public readonly partial struct OrderNumber : IDomainValue<long> { /* validation
## Getting Started

### Prerequisites
* .NET 8 or higher
* .NET 10 or higher
* NuGet Package Manager

### Installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void AddMapping()
if (!data.UnderlyingType.IsNumeric())
exampleValue = Quote(exampleValue);

builder.Append("Example = JsonValue.Create(").Append(exampleValue).AppendLine("),");
builder.Append("Examples = [JsonValue.Create(").Append(exampleValue).AppendLine(")],");
}
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal void ApplyDomainPrimitiveSchemas(OpenApiSchema domainPrimitiveSchema, b
schemaToApply.Properties = domainPrimitiveSchema.Properties;
schemaToApply.Required = domainPrimitiveSchema.Required;
schemaToApply.Description = domainPrimitiveSchema.Description;
schemaToApply.Example = domainPrimitiveSchema.Example;
schemaToApply.Examples = domainPrimitiveSchema.Examples;
schemaToApply.Enum = domainPrimitiveSchema.Enum;
schemaToApply.MinLength = domainPrimitiveSchema.MinLength;
schemaToApply.MaxLength = domainPrimitiveSchema.MaxLength;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>$(DefaultTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,41 @@ public static PrimitiveValidationResult Validate(string value)
return TestHelper.Verify(source, (_, x, _) => Assert.Equal(4, x.Count));
}

[Fact]
public Task StringValue_WithXmlExampleStringLengthAndPattern()
{
const string source = """
using AltaSoft.DomainPrimitives;

namespace AltaSoft.DomainPrimitives;

/// <summary>
/// A country code.
/// </summary>
/// <example>GE</example>
[StringLength(2, 2)]
[Pattern(@"[A-Z]{2}")]
public partial class CountryCode : IDomainValue<string>
{
/// <inheritdoc/>
public static PrimitiveValidationResult Validate(string value) => PrimitiveValidationResult.Ok;
}

/// <summary>
/// A positive amount.
/// </summary>
/// <example>42</example>
public readonly partial struct PositiveAmount : IDomainValue<int>
{
/// <inheritdoc/>
public static PrimitiveValidationResult Validate(int value) => PrimitiveValidationResult.Ok;
}

""";

return TestHelper.Verify(source);
}

[Fact]
public Task StringValue_WithTransStringLengthAndPatternWithValidation()
{
Expand Down
Loading
Loading