Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,4 @@ MigrationBackup/
# WinMerge bak files
*.bak
/switcher.json
/.claude/settings.local.json
10 changes: 10 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Test framework: **NUnit**. Test classes use `[TestFixture]` and `[Test]` attribu

## Architecture

### Code Generation

- favour duplicated code in codegeneration to have staticaly defined methods that provide performance over reflection based code.
- code generation is done by processing the UML model and creating handlebars templates

### Code Generation Pipeline

Most code in this repo is **auto-generated** — files marked `THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!` must not be edited directly.
Expand Down Expand Up @@ -104,3 +109,8 @@ Auto-generated DTOs use structured namespaces reflecting the KerML/SysML package
- CI: GitHub Actions (`CodeQuality.yml`) — builds, tests, and runs SonarQube analysis
- License: Apache 2.0 (code), LGPL v3.0 (metamodel files)
- To add a new metaclass: update the UML XMI source files, then run the code generators — do not manually create AutoGen files

## Quality rules

- Prefer comparing 'Count' to 0 rather than using 'Any()', both for clarity and for performance
- Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,48 @@ public static TransitionFeatureKind Parse(ReadOnlySpan<char> value)
throw new ArgumentException($"'{new string(value)}' is not a valid TransitionFeatureKind", nameof(value));
}

/// <summary>
/// Tries to parse the <see cref="ReadOnlySpan{Char}"/> to a <see cref="TransitionFeatureKind"/>
/// </summary>
/// <param name="value">
/// The <see cref="ReadOnlySpan{Char}"/> that is to be parsed
/// </param>
/// <param name="result">
/// When this method returns, contains the <see cref="TransitionFeatureKind"/> value equivalent
/// to the span, if the conversion succeeded, or <c>default</c> if the conversion failed.
/// </param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> was converted successfully; otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// This method is suited for string parsing
/// There are zero allocations, no boxing, Fast short-circuit evaluation
/// JIT friendly
/// </remarks>
public static bool TryParse(ReadOnlySpan<char> value, out TransitionFeatureKind result)
{
if (value.Length == 7 && value.Equals("trigger".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = TransitionFeatureKind.Trigger;
return true;
}

if (value.Length == 5 && value.Equals("guard".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = TransitionFeatureKind.Guard;
return true;
}

if (value.Length == 6 && value.Equals("effect".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = TransitionFeatureKind.Effect;
return true;
}

result = default;
return false;
}

/// <summary>
/// Parses the <see cref="ReadOnlySpan{Byte}"/> to a <see cref="TransitionFeatureKind"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,48 @@ public static VisibilityKind Parse(ReadOnlySpan<char> value)
throw new ArgumentException($"'{new string(value)}' is not a valid VisibilityKind", nameof(value));
}

/// <summary>
/// Tries to parse the <see cref="ReadOnlySpan{Char}"/> to a <see cref="VisibilityKind"/>
/// </summary>
/// <param name="value">
/// The <see cref="ReadOnlySpan{Char}"/> that is to be parsed
/// </param>
/// <param name="result">
/// When this method returns, contains the <see cref="VisibilityKind"/> value equivalent
/// to the span, if the conversion succeeded, or <c>default</c> if the conversion failed.
/// </param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> was converted successfully; otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// This method is suited for string parsing
/// There are zero allocations, no boxing, Fast short-circuit evaluation
/// JIT friendly
/// </remarks>
public static bool TryParse(ReadOnlySpan<char> value, out VisibilityKind result)
{
if (value.Length == 7 && value.Equals("private".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = VisibilityKind.Private;
return true;
}

if (value.Length == 9 && value.Equals("protected".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = VisibilityKind.Protected;
return true;
}

if (value.Length == 6 && value.Equals("public".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
result = VisibilityKind.Public;
return true;
}

result = default;
return false;
}

/// <summary>
/// Parses the <see cref="ReadOnlySpan{Byte}"/> to a <see cref="VisibilityKind"/>
/// </summary>
Expand Down
Loading