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
10 changes: 10 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ Favour duplicated, statically-defined generated methods over reflection-based co

When working on the grammar/textual-notation generator (`SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs`), read `SysML2.NET.CodeGenerator/GRAMMAR.md` for the KEBNF model, cursor/builder conventions, and existing code-gen patterns.

### OpenAPI-based generation: the `PrimitiveConstraint[Request].value` rule

The `OpenApi*Generator`s read `Resources/ptc-25-02-30.json` and emit the PSM DTOs, REST client, serializers and validators. One property in that document has no C# equivalent in its schema: `PrimitiveConstraint.value` and `PrimitiveConstraintRequest.value`. Each is `oneOf [array of oneOf(boolean | number | string | Identified | null), null]`, which `QueryCoreTypeName` cannot resolve.

- **The specific rule:** `PropertyTypeOverrides` in `SysML2.NET.CodeGenerator/Generators/OpenApiHandleBarsGenerators/OpenApiDtoGenerator.cs` maps both to `List<ConstraintValue>`. `ConstraintValue` is the hand-written tagged union `SysML2.NET/PSM/DTO/ConstraintValue.cs`.
- **The DTO generator is the single owner of that mapping.** Do not copy the override into another generator, and do not expose it for reuse. A downstream generator relies on the generated DTO already carrying `List<ConstraintValue> Value`.
- **Derive downstream rules from the schema keywords, not from the C# type.** For example, the request validator walks `schema.Properties` (minus `@type`) rather than `QueryMappableProperties`. `QueryMappableProperties` drops `value` because it is unmappable, and that would silently lose its `minItems: 1`.
- **A property the DTO lacks surfaces as a compile error** in the generated code, never as a skipped rule.

### Textual notation reviewer is MANDATORY

**Every change touching these paths MUST be verified by the `textual-notation-reviewer` agent (`.claude/agents/textual-notation-reviewer.md`) before being reported complete or committed:**
Expand Down Expand Up @@ -132,6 +141,7 @@ SysML2.NET.Serializer.TextualNotation - Writers/, AutoGenTextualNotationBuilder/
SysML2.NET.Dal - Data Access Layer (Assembler, ElementFactory)
SysML2.NET.REST - REST client + Session
SysML2.NET.Kpar - Reader/Writer for .kpar archives
SysML2.NET.Validation - FluentValidation validators for the PSM request DTOs (PSM/AutoGenValidator/, generated)
SysML2.NET.Viewer - Blazor WebAssembly app (net9.0)
SysML2.NET.CodeGenerator - Code generation tool (net10.0, not packaged)
```
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</ItemGroup>
<ItemGroup Label="Libraries">
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.7.0" />
<PackageVersion Include="FluentValidation" Version="12.2.0" />
<PackageVersion Include="MessagePack" Version="3.1.12" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.13" />
<PackageVersion Include="System.Text.Json" Version="10.0.14" />
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ project
[SysML2.NET.Kpar](https://www.nuget.org/packages/SysML2.NET.Kpar) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Kpar)
[SysML2.NET.REST](https://www.nuget.org/packages/SysML2.NET.REST) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.REST)
[SysML2.NET.DAL](https://www.nuget.org/packages/SysML2.NET.DAL) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.DAL)
[SysML2.NET.Validation](https://www.nuget.org/packages/SysML2.NET.Validation) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Validation)

The reference web-application is available on [docker-hub](https://hub.docker.com/r/stariongroup/sysml2.net.viewer). A demo-version is hosted at http://viewer.sysml2.net.

Expand All @@ -53,7 +54,7 @@ Every NuGet version is declared once, in [Directory.Packages.props](Directory.Pa

The redistributable libraries multi-target `netstandard2.1;net10.0`, so a referenced version is a **minimum floor** for every downstream consumer. The version policy follows from that:

- **Libraries** (`SysML2.NET`, `SysML2.NET.Serializer.*`, `SysML2.NET.Dal`, `SysML2.NET.REST`, `SysML2.NET.Kpar`, `SysML2.NET.Extensions`, `SysML2.NET.Semantics`) reference the lowest version that provides the APIs used. Stable framework abstractions stay at an LTS floor; serialization and cryptography packages track current.
- **Libraries** (`SysML2.NET`, `SysML2.NET.Serializer.*`, `SysML2.NET.Dal`, `SysML2.NET.REST`, `SysML2.NET.Kpar`, `SysML2.NET.Extensions`, `SysML2.NET.Semantics`, `SysML2.NET.Validation`) reference the lowest version that provides the APIs used. Stable framework abstractions stay at an LTS floor; serialization and cryptography packages track current.
- **Applications and test projects** track current versions.
- A library dependency is raised only when a required new API needs it, or when a CVE affects that package.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="BranchRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="BranchRequest"/> against the BranchRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class BranchRequestValidator : RequestValidator<BranchRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="BranchRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public BranchRequestValidator()
{
this.RuleFor(dto => dto.Head).Must(value => !value.HasValue || value.Value != Guid.Empty);
this.RuleFor(dto => dto.Name).NotEmpty();
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="CommitRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="CommitRequest"/> against the CommitRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class CommitRequestValidator : RequestValidator<CommitRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="CommitRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public CommitRequestValidator()
{
this.RuleFor(dto => dto.Change).NotNull();
this.RuleForEach(dto => dto.Change).NotNull().SetValidator(new DataVersionRequestValidator());
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="CompositeConstraintRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="CompositeConstraintRequest"/> against the CompositeConstraintRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class CompositeConstraintRequestValidator : RequestValidator<CompositeConstraintRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="CompositeConstraintRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public CompositeConstraintRequestValidator()
{
this.RuleFor(dto => dto.Constraint).NotNull();
this.RuleFor(dto => dto.Constraint).Must(value => value == null || value.Count >= 2);
this.RuleForEach(dto => dto.Constraint).NotNull();
this.RuleFor(dto => dto.Operator).IsInEnum();
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="DataIdentityRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="DataIdentityRequest"/> against the DataIdentityRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class DataIdentityRequestValidator : RequestValidator<DataIdentityRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="DataIdentityRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public DataIdentityRequestValidator()
{
this.RuleFor(dto => dto.Id).NotEmpty();
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="DataVersionRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="DataVersionRequest"/> against the DataVersionRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class DataVersionRequestValidator : RequestValidator<DataVersionRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="DataVersionRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public DataVersionRequestValidator()
{
this.RuleFor(dto => dto.Identity).SetValidator(new DataIdentityRequestValidator());
this.RuleFor(dto => dto.Payload).SetInheritanceValidator(validators =>
{
validators.Add<ExternalDataRequest>(new ExternalDataRequestValidator());
validators.Add<ExternalRelationshipRequest>(new ExternalRelationshipRequestValidator());
validators.Add<ProjectUsageRequest>(new ProjectUsageRequestValidator());
});
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="ExternalDataRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="ExternalDataRequest"/> against the ExternalDataRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class ExternalDataRequestValidator : RequestValidator<ExternalDataRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="ExternalDataRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public ExternalDataRequestValidator()
{
this.RuleFor(dto => dto.Id).Must(value => !value.HasValue || value.Value != Guid.Empty);
this.RuleFor(dto => dto.ResourceIdentifier).Must(value => value == null || value.IsAbsoluteUri);
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="ExternalRelationshipRequestValidator.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// <auto-generated />
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------

namespace SysML2.NET.Validation.PSM
{
using System;
using System.CodeDom.Compiler;

using FluentValidation;

using SysML2.NET.PSM.DTO;

/// <summary>
/// Validates a <see cref="ExternalRelationshipRequest"/> against the ExternalRelationshipRequest schema of the Systems Modeling API and Services
/// </summary>
[GeneratedCode("SysML2.NET", "latest")]
public sealed partial class ExternalRelationshipRequestValidator : RequestValidator<ExternalRelationshipRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="ExternalRelationshipRequestValidator"/> class
/// and registers its generated rules
/// </summary>
public ExternalRelationshipRequestValidator()
{
this.RuleFor(dto => dto.Id).Must(value => !value.HasValue || value.Value != Guid.Empty);
this.RuleFor(dto => dto.ElementEnd).Must(value => !value.HasValue || value.Value != Guid.Empty);
this.RuleFor(dto => dto.ExternalDataEnd).Must(value => !value.HasValue || value.Value != Guid.Empty);
}
}
}

// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
// ------------------------------------------------------------------------------------------------
Loading
Loading