Skip to content

Commit

Permalink
various polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
malstraem committed Dec 17, 2024
1 parent 53b5fed commit 46fc126
Show file tree
Hide file tree
Showing 35 changed files with 147 additions and 114 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Generate Pages
run: |
dotnet tool update -g docfx
dotnet build -c release --tl
docfx docs/docfx.json
cd docs
dotnet run -f net9.0
- name: Upload Pages
uses: actions/upload-pages-artifact@v3
with:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ jobs:
dotnet-version: |
8.x
9.x
- run: dotnet build -c release
- run: dotnet test -c release --no-build
- name: Build & Test
run: |
dotnet build -c release --tl
dotnet test -c release --no-build
- uses: actions/upload-artifact@v4
with:
path: |
docs
artifacts/bin/Arinc424
artifacts/bin/Arinc424.Docs
runs-on: ubuntu-latest
8 changes: 8 additions & 0 deletions Arinc424.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Arinc424.View.Desktop", "so
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "view", "view", "{215A2243-3232-4A54-86DE-4C376EB34DE0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{FB533D15-1C67-4DE0-AD33-7C42B5A22493}"
ProjectSection(SolutionItems) = preProject
.github\workflows\docs.yml = .github\workflows\docs.yml
.github\workflows\pack.yml = .github\workflows\pack.yml
.github\workflows\tests.yml = .github\workflows\tests.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -247,6 +254,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{989FABB9-3676-4746-AE8C-F14369DCDCBA} = {215A2243-3232-4A54-86DE-4C376EB34DE0}
{8236EEB2-1AA0-4DF8-9596-1C21D50E9462} = {215A2243-3232-4A54-86DE-4C376EB34DE0}
{FB533D15-1C67-4DE0-AD33-7C42B5A22493} = {1D87B9E7-6D26-4F2E-9015-504EA5B60AF3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F25034B4-EEAF-411A-B0D5-9F307674AB8B}
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />

<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0-pre.49" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />

<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />

Expand Down
2 changes: 2 additions & 0 deletions docs/Arinc424.Docs.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0</TargetFrameworks>

<OutputType>exe</OutputType>

<AppDesignerFolder>properties</AppDesignerFolder>
Expand Down
5 changes: 1 addition & 4 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@
"dest": "api/",
"enumSortOrder": "declaringOrder",
"namespaceLayout": "nested",
"noRestore": true,
"src": [
{
"files": [
"source/library/Arinc424.csproj"
],
"files": [ "artifacts/bin/Arinc424/release_net9.0/Arinc424.dll" ],
"src": "../"
}
]
Expand Down
10 changes: 4 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ While the **ARINC 424** specification describes entities (or records) with 132-b

Most terms are converted according to the specification into associated enumerations or numeric values ​​on the fly.

In addition, relationships between entities are established after the building stage.

In practice, this allows you to explore and manipulate the tree-like representation of **ARINC 424** database.
In addition, relationships between entities are established after the building stage. In practice, this allows you to explore and manipulate the tree-like representation of **ARINC 424** database.

## Specification map

Expand All @@ -19,7 +17,7 @@ In practice, this allows you to explore and manipulate the tree-like representat

- [VHF Navaid](api/Arinc424.Navigation.Omnidirectional.yml)
- [NDB Navaid](api/Arinc424.Navigation.Nondirectional.yml)
- [TACAN](api/Arinc424.Navigation.Tactical.yml) 🚧
- [TACAN](api/Arinc424.Navigation.Tactical.yml)

# [Enroute](#tab/enroute)

Expand Down Expand Up @@ -76,8 +74,8 @@ In practice, this allows you to explore and manipulate the tree-like representat

# [Airspace](#tab/airspace)

- [Controlled Airspace](api/Arinc424.Airspace.ControlledSpace.yml)
- [Controlled](api/Arinc424.Airspace.ControlledSpace.yml)
- [FIR/UIR](api/Arinc424.Airspace.FlightRegion.yml)
- [Restrictive Airspace](api/Arinc424.Airspace.RestrictiveSpace.yml)
- [Restrictive](api/Arinc424.Airspace.RestrictiveSpace.yml)

---
4 changes: 1 addition & 3 deletions docs/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ While the **ARINC 424** specification describes entities (or records) with 132-b

Most terms are converted according to the specification into associated enumerations or numeric values ​​on the fly.

In addition, relationships between entities are established after the building stage.

In practice, this allows you to explore and manipulate the tree-like representation of **ARINC 424** database.
In addition, relationships between entities are established after the building stage. In practice, this allows you to explore and manipulate the tree-like representation of **ARINC 424** database.

See [docs](https://malstraem.github.io/arinc424.net) to know how specification is mapped.

Expand Down
4 changes: 1 addition & 3 deletions source/library/Arinc424.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Arinc424</RootNamespace>

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -21,7 +19,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

<Version>0.1.0-alpha</Version>
<Version>0.1.1-alpha</Version>
<PackageId>arinc424</PackageId>
<Product>ARINC 424 object model</Product>

Expand Down
2 changes: 1 addition & 1 deletion source/library/building/ArrayAssignment{TRecord, TType}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal override void Assign(TRecord record, ReadOnlySpan<char> @string, Queue<
var result = decode.Convert(@field);

if (result.Invalid)
diagnostics.Enqueue(new InvalidValue(record, Property, result.Bad.ToImmutableArray(), range));
diagnostics.Enqueue(new InvalidValue(record, property, result.Bad.ToImmutableArray(), range));
else
values.Add(result.Value);

Expand Down
6 changes: 3 additions & 3 deletions source/library/building/Assignment{TRecord}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace Arinc424.Building;
/// </summary>
internal abstract class Assignment<TRecord>(PropertyInfo property) where TRecord : Record424
{
internal Regex? Regex { get; } = property.GetCustomAttribute<ValidationAttribute>()?.Regex;
protected PropertyInfo property = property;

internal PropertyInfo Property { get; } = property;
internal Regex? Regex { get; } = property.GetCustomAttribute<ValidationAttribute>()?.Regex;

internal NullabilityInfo NullabilityInfo { get; } = new NullabilityInfoContext().Create(property);
internal NullabilityInfo? NullabilityInfo { get; } = property.PropertyType.IsClass ? new NullabilityInfoContext().Create(property) : null;

internal abstract void Assign(TRecord record, ReadOnlySpan<char> @string, Queue<Diagnostic> diagnostics);
}
4 changes: 2 additions & 2 deletions source/library/building/IndexAssignment{TRecord}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Arinc424.Building;

[DebuggerDisplay($"{{{nameof(Property)}}} - {{{nameof(index)}}}")]
[DebuggerDisplay($"{{{nameof(property)}}} - {{{nameof(index)}}}")]
internal abstract class IndexAssignment<TRecord>(PropertyInfo property, int index)
: Assignment<TRecord>(property) where TRecord : Record424
{
Expand All @@ -25,7 +25,7 @@ internal override void Assign(TRecord record, ReadOnlySpan<char> @string, Queue<
if (transform.TryConvert(@char, out var value))
set(record, value);
else
diagnostics.Enqueue(new InvalidValue(record, Property, [@char], index..index));
diagnostics.Enqueue(new InvalidValue(record, property, [@char], index..index));
}
}

Expand Down
28 changes: 9 additions & 19 deletions source/library/building/RangeAssignment{TRecord}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Arinc424.Building;

[DebuggerDisplay($"{{{nameof(Property)}}} - {{{nameof(range)}}}")]
[DebuggerDisplay($"{{{nameof(property)}}} - {{{nameof(range)}}}")]
internal abstract class RangeAssignment<TRecord>(PropertyInfo property, Range range) : Assignment<TRecord>(property) where TRecord : Record424
{
protected readonly Range range = range;
Expand Down Expand Up @@ -44,19 +44,14 @@ internal override void Assign(TRecord record, ReadOnlySpan<char> @string, Queue<

if (@field.IsWhiteSpace())
{
// todo: process nullability by provided conditional settings

/*if (NullabilityInfo.WriteState is NullabilityState.NotNull)
{
diagnostic = new NullDiagnostic(record, $"Property {Property} does not allow blank values.", range);
return false;
}*/
if (NullabilityInfo?.WriteState is NullabilityState.NotNull)
diagnostics.Enqueue(new Nullability(record, property, range));
return;
}
var result = decode.Convert(@field);

if (result.Invalid)
diagnostics.Enqueue(new InvalidValue(record, Property, result.Bad.ToImmutableArray(), range));
diagnostics.Enqueue(new InvalidValue(record, property, result.Bad.ToImmutableArray(), range));
else
set(record, result.Value);
}
Expand All @@ -69,19 +64,14 @@ internal sealed class StringAssignment<TRecord>(PropertyInfo property, Range ran

internal override void Assign(TRecord record, ReadOnlySpan<char> @string, Queue<Diagnostic> diagnostics)
{
var @field = @string[range];
var @field = @string[range].Trim();

if (@field.IsWhiteSpace())
if (@field.IsEmpty)
{
// todo: process nullability by provided conditional settings

/*if (NullabilityInfo.WriteState is NullabilityState.NotNull)
{
diagnostic = new NullDiagnostic(record, $"Property {Property} does not allow blank values.", range);
return false;
}*/
if (NullabilityInfo?.WriteState is NullabilityState.NotNull)
diagnostics.Enqueue(new Nullability(record, property, range));
return;
}
set(record, @field.Trim().ToString());
set(record, @field.ToString());
}
}
4 changes: 2 additions & 2 deletions source/library/converters/comms/RadarAvailabilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public static bool TryConvert(char @char, out Bool value)
{
switch (@char)
{
case (char)32:
value = Bool.Unspecified; return true;
case 'R':
value = Bool.Yes; return true;
case 'N':
value = Bool.No; return true;
case 'U' or (char)32:
value = Bool.Unspecified; return true;
default:
value = Bool.Unknown; return false;
}
Expand Down
2 changes: 0 additions & 2 deletions source/library/diagnostics/InvalidLink.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Reflection;

using Arinc424.Linking;

namespace Arinc424.Diagnostics;

public class InvalidLink(Record424 record, PropertyInfo property, LinkInfo info, LinkError error)
Expand Down
5 changes: 0 additions & 5 deletions source/library/diagnostics/Null.cs

This file was deleted.

5 changes: 5 additions & 0 deletions source/library/diagnostics/Nullability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Reflection;

namespace Arinc424.Diagnostics;

public class Nullability(Record424 record, PropertyInfo property, Range range) : RangeDiagnostic(DiagnosticType.Null, record, property, range);
7 changes: 5 additions & 2 deletions source/library/processing/AirwayPointSorting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ namespace Arinc424.Processing;
/// </summary>
internal class AirwayPointSorting : IPipeline<AirwayPoint, AirwayPoint>
{
private readonly Range identifierRange = 13..18;
/// <summary>
/// Airway identifier range.
/// </summary>
private readonly Range range = 13..18;

public Queue<Build<AirwayPoint>> Process(Queue<Build<AirwayPoint>> builds)
{
if (builds.Count == 0)
return builds;

var sorted = builds.OrderBy(x => x.Record.Source![identifierRange]);
var sorted = builds.OrderBy(x => x.Record.Source![range]);

return new Queue<Build<AirwayPoint>>(sorted);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ internal sealed class CommWrapBeforeV19<TComm, TTransmitter>(Supplement suppleme
where TComm : Communication<TTransmitter>, new()
where TTransmitter : Transmitter
{
/// <summary>
/// <see cref="IIdentity.Identifier"/> range.
/// </summary>
private readonly Range range = 6..10;

protected override bool Trigger(TTransmitter current, TTransmitter next) => current.Source![range] != next.Source![range];
Expand Down
42 changes: 42 additions & 0 deletions source/library/processing/ControlledConcatenate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Arinc424.Airspace;
using Arinc424.Building;
using Arinc424.Diagnostics;

namespace Arinc424.Processing;

internal class ControlledConcatenate(Supplement supplement) : IPipeline<ControlledSpace, ControlledVolume>
{
/// <summary>
/// <see cref="Space{TVolume}.Name"/> range.
/// </summary>
private readonly Range range = 93..123;

private readonly BuildInfo<ControlledSpace> info = new(supplement);

public Queue<Build<ControlledSpace>> Process(Queue<Build<ControlledVolume>> builds)
{
Queue<Build<ControlledSpace>> spaces = [];

if (builds.Count == 0)
return spaces;

Queue<Diagnostic> diagnostics = [];

Dictionary<string, Queue<Build<ControlledVolume>>> buffer = [];

foreach (var build in builds)
{
string name = build.Record.Source![range].Trim();

if (!buffer.TryGetValue(name, out var volumes))
volumes = buffer[name] = [];

volumes.Enqueue(build);
}

foreach (var (name, volumes) in buffer)
spaces.Enqueue(RecordBuilder<ControlledSpace, ControlledVolume>.Build(volumes, info, ref diagnostics));

return spaces;
}
}
2 changes: 1 addition & 1 deletion source/library/processing/Scan{TOut, TSource, TTrigger}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal abstract class Scan<TOut, TSource> : IPipeline<TOut, TSource> where TOu
/// <remarks>All overrides should dequeue <paramref name="sources"/>.</remarks>
protected abstract Build<TOut> Build(Queue<Build<TSource>> sources, ref Queue<Diagnostic> diagnostics);

public Queue<Build<TOut>> Process(Queue<Build<TSource>> builds)
public virtual Queue<Build<TOut>> Process(Queue<Build<TSource>> builds)
{
Build<TSource> next, current;

Expand Down
8 changes: 0 additions & 8 deletions source/library/processing/Sequence{TSequence, TSub}.cs

This file was deleted.

Loading

0 comments on commit 46fc126

Please sign in to comment.