Skip to content

Commit

Permalink
link markers with ils, code polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
malstraem committed Feb 10, 2025
1 parent 8f9b617 commit dfdd300
Show file tree
Hide file tree
Showing 39 changed files with 397 additions and 434 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />

<PackageVersion Include="TUnit" Version="0.10.28" />
<PackageVersion Include="TUnit" Version="0.11.0" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions source/library/Supplement.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace Arinc424;

/// <summary>
/// Version in terms of the <c>ARINC 424</c> specification.
/// </summary>
/// <summary>Version in terms of the <c>ARINC 424</c> specification.</summary>
public enum Supplement : byte
{
V18 = 18,
Expand Down
10 changes: 5 additions & 5 deletions source/library/attributes/IndexAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies the index within an <c>ARINC-424</c> string.
/// </summary>
/// <remarks>Note that the index are exactly the same as those defined in the specification.</remarks>
internal abstract class IndexAttribute(int index, Supplement supplement) : SupplementAttribute(supplement)
/**<summary>
Specifies the index within an <c>ARINC-424</c> string.
</summary>
<remarks>Note that the index are exactly the same as those defined in the specification.</remarks>*/
internal abstract class IndexAttribute(int index) : SupplementAttribute
{
internal int Index { get; } = index - 1;
}
10 changes: 5 additions & 5 deletions source/library/attributes/RangeAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies the range of a field within an <c>ARINC-424</c> string.
/// </summary>
/// <remarks>Note that the bounds are exactly the same as those defined in the specification.</remarks>
internal abstract class RangeAttribute(int left, int right, Supplement start) : SupplementAttribute(start)
/**<summary>
Specifies the range of a field within an <c>ARINC-424</c> string.
</summary>
<remarks>Note that the bounds are exactly the same as those defined in the specification.</remarks>*/
internal abstract class RangeAttribute(int left, int right) : SupplementAttribute
{
internal Range Range { get; } = new Range(left - 1, right);
}
20 changes: 9 additions & 11 deletions source/library/attributes/SupplementAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
namespace Arinc424.Attributes;

/// <summary>
/// A base attribute that can be versioned.
/// </summary>
internal abstract class SupplementAttribute(Supplement start, Supplement end = Supplement.V23) : Attribute
/// <summary>A base attribute that can be versioned.</summary>
internal abstract class SupplementAttribute : Attribute
{
internal Supplement Start { get; } = start;
public Supplement Start { get; set; } = Supplement.V18;

internal Supplement End { get; } = end;
public Supplement End { get; set; } = Supplement.V23;

internal virtual bool IsTarget => false;

/// <summary>
/// Defines that a type matches the attribute.
/// </summary>
/// <typeparam name="TMatch">Type to match.</typeparam>
/// <remarks><see langword="False"/> is forced cause non target attribute will be come by default.</remarks>
/**<summary>
Defines that a type matches the attribute.
</summary>
<typeparam name="TMatch">Type to match.</typeparam>
<remarks><see langword="false"/> is forced cause non target attribute will be come by default.</remarks>*/
internal virtual bool IsMatch<TMatch>() where TMatch : Record424 => false;
}
23 changes: 11 additions & 12 deletions source/library/attributes/building/CharacterAttribute{TRecord}.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies the index of a character within an <c>ARINC-424</c> string. Comes before <see cref="CharacterAttribute{TRecord}"/>.
/// </summary>
/// <inheritdoc/>
/**<summary>
Specifies the index of a character within an <c>ARINC-424</c> string. Comes before <see cref="CharacterAttribute{TRecord}"/>.
</summary>
<inheritdoc/>*/
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
internal class CharacterAttribute(int index, Supplement start = Supplement.V18) : IndexAttribute(index, start);
internal class CharacterAttribute(int index) : IndexAttribute(index);

/// <summary>
/// Specifies the target character index for <typeparamref name="TRecord"/> within an <c>ARINC-424</c> string.
/// </summary>
/// <inheritdoc/>
/// <typeparam name="TRecord">Target type of record that index is defined.</typeparam>
internal sealed class CharacterAttribute<TRecord>(int index, Supplement start = Supplement.V18) : CharacterAttribute(index, start)
where TRecord : Record424
/**<summary>
Specifies the target character index for <typeparamref name="TRecord"/> within an <c>ARINC-424</c> string.
</summary>
<inheritdoc/>
<typeparam name="TRecord">Target type of record that index is defined.</typeparam>*/
internal sealed class CharacterAttribute<TRecord>(int index) : CharacterAttribute(index) where TRecord : Record424
{
internal override bool IsMatch<TMatch>() => typeof(TMatch).IsAssignableTo(typeof(TRecord));

Expand Down
10 changes: 5 additions & 5 deletions source/library/attributes/building/ContinuousAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies the index of <c>Continuation Record Number (CONT NR)</c> within an <c>ARINC-424</c> string. Default is 22.
/// </summary>
/// <remarks>See section 5.16.</remarks>
/**<summary>
Specifies the index of <c>Continuation Record Number (CONT NR)</c> within an <c>ARINC-424</c> string. Default is 22.
</summary>
<remarks>See section 5.16.</remarks>*/
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
internal class ContinuousAttribute(int index = 22, Supplement supplement = Supplement.V18) : IndexAttribute(index, supplement);
internal class ContinuousAttribute(int index = 22) : IndexAttribute(index);
23 changes: 11 additions & 12 deletions source/library/attributes/building/FieldAttribute{TRecord}.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies the range of a field within an <c>ARINC-424</c> string. Comes before <see cref="FieldAttribute{TRecord}"/>.
/// </summary>
/// <inheritdoc/>
/**<summary>
Specifies the range of a field within an <c>ARINC-424</c> string. Comes before <see cref="FieldAttribute{TRecord}"/>.
</summary>
<inheritdoc/>*/
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
internal class FieldAttribute(int left, int right, Supplement start = Supplement.V18) : RangeAttribute(left, right, start);
internal class FieldAttribute(int left, int right) : RangeAttribute(left, right);

/// <summary>
/// Specifies the target field range for <typeparamref name="TRecord"/> within an <c>ARINC-424</c> string.
/// </summary>
/// <inheritdoc/>
/// <typeparam name="TRecord">Target record type in which the field is defined.</typeparam>
internal sealed class FieldAttribute<TRecord>(int left, int right, Supplement start = Supplement.V18) : FieldAttribute(left, right, start)
where TRecord : Record424
/**<summary>
Specifies the target field range for <typeparamref name="TRecord"/> within an <c>ARINC-424</c> string.
</summary>
<inheritdoc/>
<typeparam name="TRecord">Target record type in which the field is defined.</typeparam>*/
internal sealed class FieldAttribute<TRecord>(int left, int right) : FieldAttribute(left, right) where TRecord : Record424
{
internal override bool IsMatch<TMatch>() => typeof(TMatch).IsAssignableTo(typeof(TRecord));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies that the string will be converted before assignment using <see cref="FieldAttribute"/> range.
/// </summary>
internal abstract class DecodeAttribute(Supplement start) : SupplementAttribute(start);
/**<summary>
Specifies that the string will be converted before assignment
using <see cref="FieldAttribute"/> range.
</summary>*/
internal abstract class DecodeAttribute : SupplementAttribute;

/// <inheritdoc/>
/// <typeparam name="TType">The type of value being converted from the string.</typeparam>
internal abstract class DecodeAttribute<TType>(Supplement start = Supplement.V18) : DecodeAttribute(start) where TType : notnull
internal abstract class DecodeAttribute<TType> : DecodeAttribute where TType : notnull
{
internal abstract Result<TType> Convert(ReadOnlySpan<char> @string);
}

/// <inheritdoc/>
/// <typeparam name="TConverter">Associated <see cref="IStringConverter{TType}"/>.</typeparam>
/// <typeparam name="TType"> <inheritdoc/> </typeparam>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Property, AllowMultiple = true)]
internal class DecodeAttribute<TConverter, TType>(Supplement start = Supplement.V18) : DecodeAttribute<TType>(start)
/** <inheritdoc/>
<typeparam name="TConverter">Associated <see cref="IStringConverter{TType}"/>.</typeparam>
<typeparam name="TType"><inheritdoc/></typeparam>*/
[AttributeUsage(AttributeTargets.Struct
| AttributeTargets.Class
| AttributeTargets.Enum
| AttributeTargets.Property,
AllowMultiple = true)]
internal class DecodeAttribute<TConverter, TType> : DecodeAttribute<TType>
where TConverter : IStringConverter<TType>
where TType : notnull
{
internal override Result<TType> Convert(ReadOnlySpan<char> @string) => TConverter.Convert(@string);
}

/// <inheritdoc/>
/// <typeparam name="TConverter">Associated <see cref="IStringConverter{TType}"/>.</typeparam>
/// <typeparam name="TType"> <inheritdoc/> </typeparam>
/// <typeparam name="TRecord">The target record type for which the attribute applies.</typeparam>
internal sealed class DecodeAttribute<TConverter, TType, TRecord>(Supplement start = Supplement.V18) : DecodeAttribute<TConverter, TType>(start)
/**<inheritdoc/>
<typeparam name="TConverter">Associated <see cref="IStringConverter{TType}"/>.</typeparam>
<typeparam name="TType"><inheritdoc/></typeparam>
<typeparam name="TRecord">The target record type for which the attribute applies.</typeparam>*/
internal sealed class DecodeAttribute<TConverter, TType, TRecord> : DecodeAttribute<TConverter, TType>
where TConverter : IStringConverter<TType>
where TType : notnull
where TRecord : Record424
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies that the character will be converted before assignment using <see cref="CharacterAttribute"/> index.
/// </summary>
internal abstract class TransformAttribute(Supplement start) : SupplementAttribute(start);
/**<summary>
Specifies that the character will be converted before assignment
using <see cref="CharacterAttribute"/> index.
</summary>*/
internal abstract class TransformAttribute : SupplementAttribute;

/// <inheritdoc/>
/// <typeparam name="TType">The type of value being converted from the character.</typeparam>
internal abstract class TransformAttribute<TType>(Supplement start) : TransformAttribute(start) where TType : Enum
internal abstract class TransformAttribute<TType> : TransformAttribute where TType : Enum
{
internal abstract bool TryConvert(char @char, out TType value);
}

/// <inheritdoc/>
/// <typeparam name="TConverter">Associated <see cref="ICharConverter{TType}"/>.</typeparam>
/// <typeparam name="TType"> <inheritdoc/> </typeparam>
/// <typeparam name="TType"><inheritdoc/></typeparam>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Enum, AllowMultiple = true)]
internal sealed class TransformAttribute<TConverter, TType>(Supplement start = Supplement.V18) : TransformAttribute<TType>(start)
internal sealed class TransformAttribute<TConverter, TType> : TransformAttribute<TType>
where TConverter : ICharConverter<TType>
where TType : Enum
{
internal override bool TryConvert(char @char, out TType value) => TConverter.TryConvert(@char, out value);
internal override bool TryConvert(char @char, out TType value)
=> TConverter.TryConvert(@char, out value);
}
6 changes: 2 additions & 4 deletions source/library/attributes/linking/IdentifierAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace Arinc424.Attributes;

/// <summary>
/// Specifies <see cref="IIdentity.Identifier"/> range for linking.
/// </summary>
/// <summary>Specifies <see cref="IIdentity.Identifier"/> range for linking.</summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
internal class IdentifierAttribute(int left, int right, Supplement start = Supplement.V18) : RangeAttribute(left, right, start)
internal class IdentifierAttribute(int left, int right) : RangeAttribute(left, right)
{
internal virtual Link<TRecord> GetLink<TRecord>(PropertyInfo property, Supplement supplement) where TRecord : Record424
{
Expand Down
4 changes: 2 additions & 2 deletions source/library/attributes/linking/LinkAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ namespace Arinc424.Attributes;
/// Specifies <c>Airport/Heliport</c> identifier range.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
internal class PortAttribute(int left, int right, Supplement start = Supplement.V18) : RangeAttribute(left, right, start);
internal class PortAttribute(int left, int right) : RangeAttribute(left, right);

/// <summary>
/// Specifies <c>ICAO Code</c> range.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
internal class IcaoAttribute(int left, int right, Supplement start = Supplement.V18) : RangeAttribute(left, right, start);
internal class IcaoAttribute(int left, int right) : RangeAttribute(left, right);

/// <summary>
/// Specifies that the property is one-to-many and relationships will be established after parsing.
Expand Down
14 changes: 4 additions & 10 deletions source/library/attributes/linking/TypeAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
namespace Arinc424.Attributes;

/// <summary>
/// Specifies indexes of section and subsection code to define related entity type.
/// </summary>
/// <summary>Specifies indexes of section and subsection code to define related entity type.</summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
internal class TypeAttribute(int sectionIndex, int subsectionIndex, Supplement start = Supplement.V18) : SupplementAttribute(start)
internal class TypeAttribute(int sectionIndex, int subsectionIndex) : SupplementAttribute
{
/// <summary>
/// Index of the section character.
/// </summary>
/// <summary>Index of the section character.</summary>
internal int SectionIndex = sectionIndex - 1;

/// <summary>
/// Index of the subsection character.
/// </summary>
/// <summary>Index of the subsection character.</summary>
internal int SubsectionIndex = subsectionIndex - 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

namespace Arinc424.Attributes;

internal abstract class PipelineAttribute(Supplement start, Supplement end) : SupplementAttribute(start, end)
internal abstract class PipelineAttribute : SupplementAttribute
{
internal abstract IPipeline GetPipeline(Supplement supplement);
}

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
internal sealed class PipelineAttribute<TPipeline>(Supplement start = Supplement.V18, Supplement end = Supplement.V23)
: PipelineAttribute(start, end)
where TPipeline : IPipeline
internal sealed class PipelineAttribute<TPipeline> : PipelineAttribute where TPipeline : IPipeline
{
internal override IPipeline GetPipeline(Supplement supplement)
{
Expand Down
69 changes: 39 additions & 30 deletions source/library/records/Fix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,49 @@

namespace Arinc424;

/// <summary>
/// Base fix with an identifier used as a navigation point.
/// </summary>
public abstract class Fix : Geo, IIdentity
/// <summary>Base object with an identifier used as a navigation point.</summary>
public abstract class Fix : Geo, IIcao, IIdentity
{
/// <summary>
/// <para>
/// <c>Airport/Heliport Identifier (ARPT/HELI IDENT)</c> field for <see cref="Airport"/> and <see cref="Heliport"/>. See section 5.6.
/// </para>
/// <para>
/// <c>Fix Identifier (FIX IDENT)</c> field for <see cref="TerminalWaypoint"/> and <see cref="Waypoint"/>. See section 5.13.
/// </para>
/// <para>
/// <c>VOR/NDB Identifier (VOR IDENT/NDB IDENT)</c> field for <see cref="Omnidirectional"/>,
/// <see cref="Nondirectional"/> and <see cref="Tactical"/>. See section 5.33.
/// </para>
/// <para>
/// <c>Localizer/MLS/GLS Identifier (LOC, MLS, GLS IDENT)</c> field for <see cref="InstrumentLanding"/>, <see cref="InstrumentMarker"/>,
/// <see cref="MicrowaveLanding"/> and <see cref="GlobalLanding"/>. See section 5.44.
/// </para>
/// <para>
/// <c>Runway Identifier (RUNWAY ID)</c> field for <see cref="RunwayThreshold"/>. See section 5.46.
/// </para>
/// <para>
/// <c>Marker Identifier (MARKER IDENT)</c> field for <see cref="AirwayMarker"/>. See section 5.110.
/// </para>
/// <para>
/// <c>Reference Path Identifier (REF ID)</c> field for <see cref="GroundPoint"/> and <see cref="SatellitePoint"/>. See section 5.257.
/// </para>
/// </summary>
[Field(11, 12)]
[Field<Waypoint>(20, 21)]
[Field<AirwayMarker>(20, 21)]
[Field<Nondirectional>(20, 21)]
[Field<Omnidirectional>(20, 21)]
public string Icao { get; set; }

/**<summary>
<para>
<c>Airport/Heliport Identifier (ARPT/HELI IDENT)</c> field for <see cref="Airport"/> and <see cref="Heliport"/>. See section 5.6.
</para>
<para>
<c>Fix Identifier (FIX IDENT)</c> field for <see cref="TerminalWaypoint"/> and <see cref="Waypoint"/>. See section 5.13.
</para>
<para>
<c>VOR/NDB Identifier (VOR IDENT/NDB IDENT)</c> field for <see cref="Omnidirectional"/>,
<see cref="Nondirectional"/> and <see cref="Tactical"/>. See section 5.33.
</para>
<para>
<c>Localizer/MLS/GLS Identifier (LOC, MLS, GLS IDENT)</c> field for <see cref="InstrumentLanding"/>, <see cref="InstrumentMarker"/>,
<see cref="MicrowaveLanding"/> and <see cref="GlobalLanding"/>. See section 5.44.
</para>
<para>
<c>Runway Identifier (RUNWAY ID)</c> field for <see cref="RunwayThreshold"/>. See section 5.46.
</para>
<para>
<c>Gate Identifier (GATE IDENT)</c> field for <see cref="Gate"/>. See section 5.56.
</para>
<para>
<c>Marker Identifier (MARKER IDENT)</c> field for <see cref="AirwayMarker"/>. See section 5.110.
</para>
<para>
<c>Reference Path Identifier (REF ID)</c> field for <see cref="GroundPoint"/> and <see cref="SatellitePoint"/>. See section 5.257.
</para>
</summary>*/
[Field(14, 17)]
[Field<Port>(7, 10)]
[Field<RunwayThreshold>(14, 18)]
[Field<Gate>(14, 18)]
[Field<Waypoint>(14, 18)]
[Field<PathPoint>(33, 36)]
[Field<RunwayThreshold>(14, 18)]
public string Identifier { get; set; }
}
Loading

0 comments on commit dfdd300

Please sign in to comment.